diff --git a/.github/workflows/sync-and-analyze.yml b/.github/workflows/sync-and-analyze.yml deleted file mode 100644 index 25d73a39..00000000 --- a/.github/workflows/sync-and-analyze.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Sync and Analyze - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - sync-and-scan: - permissions: - contents: read - security-events: write - actions: read - runs-on: ubuntu-latest - steps: - - name: Checkout source repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.PERSONAL_TOKEN }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "8.2" - extensions: xdebug - coverage: xdebug - - - name: Install Dependencies - run: composer install --no-interaction --no-progress - - - name: Run test suite with coverage - run: vendor/bin/phpunit --coverage-clover coverage.xml - - - name: Fix code coverage paths - run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace@g' coverage.xml - - - name: Sync repositories - run: | - git config --global user.name 'JosueUPT' - git config --global user.email '${{ secrets.GIT_EMAIL }}' - git add composer.lock - git commit -m "Update composer.lock" || echo "No changes to commit" - git push || echo "No changes to push" - git clone https://${{ secrets.PERSONAL_TOKEN }}@github.com/JosueUPT/CalidadU2.git ../CalidadU2 - rsync -av --exclude='.git' --exclude='.github/workflows/sync-and-analyze.yml' --exclude='temp_repo' ./ ../CalidadU2/ - cd ../CalidadU2 - git add . - git commit -m "Sync: Update from source repository" || echo "No changes to commit" - git push origin main || echo "No changes to push" - cd .. - - - name: Run Semgrep Security Scan - uses: semgrep/semgrep-action@v1 - env: - SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} - SEMGREP_DEPLOYMENT_ID: "pyfange" - SEMGREP_REPO_NAME: ${{ github.repository }} - SEMGREP_BRANCH: ${{ github.ref_name }} - with: - publishToken: ${{ secrets.SEMGREP_APP_TOKEN }} - - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - name: Install Snyk CLI - run: | - curl https://static.snyk.io/cli/latest/snyk-linux -o snyk - chmod +x snyk - sudo mv snyk /usr/local/bin/ - diff --git a/.phpunit.result.cache b/.phpunit.result.cache index 705955cb..c56ccb67 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -{"version":1,"defects":{"Tests\\Unit\\Controllers\\ProductControllerTest::testGetProductById":8,"Tests\\Unit\\Controllers\\ProductControllerTest::testCreateProduct":8,"Tests\\Unit\\Controllers\\UserControllerTest::el_registro_de_usuario_debe_ser_exitoso":8,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_ser_exitoso_con_credenciales_correctas":8,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_fallar_con_credenciales_incorrectas":8,"Tests\\Unit\\Controllers\\UserControllerTest::debe_obtener_usuario_por_id_correctamente":8,"Tests\\Unit\\Controllers\\ProductControllerTest::get_product_by_id":8,"Tests\\Unit\\Controllers\\ProductControllerTest::create_product":8,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_success":7,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_user_not_found":8,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_already_sent":7,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_save_error":7,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_throws_exception":7,"Warning":6,"Tests\\Unit\\Controllers\\UserControllerTest::logout_exitoso":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testValidateImageName":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithLargeImage":4,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProductNotFound":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrderDatabaseError":4,"Tests\\Unit\\Models\\MessageTest::verifica_si_mensaje_existe":3,"Tests\\Unit\\Models\\MessageTest::verifica_mensaje_no_existente":3,"Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia":4,"Tests\\Unit\\Config\\DatabaseTest::puede_obtener_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::maneja_error_de_conexion":3,"Tests\\Unit\\Config\\DatabaseTest::verifica_singleton_pattern":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_propiedades_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_charset_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_collation_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_timezone_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_max_connections":4,"Tests\\Unit\\Config\\DatabaseTest::connect_lanza_database_exception":4,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_charset_utf8":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_corrupto":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_getenv_cuando_disponible":4,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_atributos_pdo":4,"Tests\\Unit\\Config\\DatabaseTest::connect_registra_error_antes_de_lanzar_excepcion":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_carga_variables_desde_env_file":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_valores_por_defecto_sin_env":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_no_existente":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_invalido":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_variables_de_entorno":4,"Tests\\Unit\\Config\\DatabaseTest::connect_establece_conexion_exitosa":4,"Tests\\Unit\\Config\\DatabaseTest::connect_maneja_error_de_conexion":4,"Tests\\Unit\\Controllers\\UserControllerTest::logout_maneja_error_session_start":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_conexion_exitosa":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_error_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_valores_por_defecto":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_manejo_error_conexion":4,"Tests\\Unit\\Controllers\\UserControllerTest::test_logout_limpia_sesion":3,"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_usuario_no_existe":3,"Tests\\Unit\\Controllers\\UserControllerTest::logout_limpia_sesion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_variables_entorno":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env_file":4,"Tests\\Unit\\IndexTest::redirige_a_admin_si_usuario_es_admin":4,"Tests\\Unit\\IndexTest::redirige_a_home_si_usuario_no_es_admin":4,"Tests\\Unit\\IndexTest::redirige_a_login_si_no_hay_sesion":4,"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion":3,"Tests\\Unit\\Controllers\\UserControllerTest::login_exitoso_con_admin":3,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_valores_por_defecto":4,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_carga_variables_entorno":4,"Tests\\Unit\\Config\\DatabaseTest::test_lanza_excepcion_con_credenciales_invalidas":4,"Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion":4,"Tests\\Unit\\Views\\ShopTest::test_redirige_si_no_hay_sesion":4,"Tests\\Unit\\Views\\ShopTest::test_puede_obtener_productos":4,"Tests\\UI\\Pages\\ShopPageTest::testVerProductosEnTienda":4,"Tests\\UI\\Pages\\ShopPageTest::testAgregarProductoAlCarrito":4,"Tests\\UI\\Pages\\LoginPageTest::testLoginPageElements":3,"Tests\\UI\\Pages\\LoginPageTest::testLoginAttempt":3,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginVisual":3,"Tests\\UI\\Pages\\LoginPageTest::testUserLoginVisual":3,"Tests\\UI\\Pages\\LoginPageTest::testLoginFailure":3,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLogoutVisual":3,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearch":4,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearchWithResults":4,"Tests\\UI\\Pages\\SearchPageTest::testSearchWithNoResults":4,"Tests\\UI\\Pages\\ShopPageTest::testShopPageLoadsWithProducts":4,"Tests\\UI\\Pages\\ShopPageTest::testAddProductToCart":4,"Tests\\UI\\Pages\\ShopPageTest::testAddNewProductToCart":3,"Tests\\UI\\Pages\\ShopPageTest::testProceedToCheckoutAndPlaceOrder":3,"Tests\\UI\\Pages\\ShopPageTest::testViewOrders":3,"Tests\\UI\\Pages\\ShopPageTest::testUpdateProductQuantityInCart":3,"Tests\\UI\\Pages\\ContactPageTest::testSendContactForm":4,"Tests\\UI\\Pages\\AdminProductTest::testAddAndUpdateProduct":4,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginFailure":3,"Tests\\UI\\Pages\\AdminOrderTest::testUpdateOrderStatus":4,"Tests\\UI\\Pages\\AdminUsersMessagesTest::testViewUsersAndMessagesAndLogout":3,"Tests\\UI\\Pages\\RegisterPageTest::testUserRegisterSuccess":3,"Tests\\UI\\Pages\\ShopPageTest::testAddDuplicateProductToCart":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductMutation":3,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutation":3,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutation":4,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationSuccess":3,"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusMutation":3,"Tests\\Mutation\\OrderControllerMutationTest::testDeleteOrderMutation":3,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityMutation":3,"Tests\\Mutation\\ProductControllerMutationTest::testDeleteCartItemMutation":3,"Tests\\Unit\\AutoloadTest::test_puede_cargar_clase_existente":1,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityWithInvalidQuantity":3,"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartWithInvalidData":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllOrdersMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllProductsMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllUsersMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserMutation":3,"Tests\\Mutation\\DatabaseMutationTest::testInvalidEnvFileMutation":4,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyMessageMutation":3,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyNameMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithSQLInjectionAttemptMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageWithInvalidIDMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductWithInvalidExtensionMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderWithDatabaseErrorMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusWithInvalidIDMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataWithErrorMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithZeroResultMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesWithDatabaseErrorMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserWithNonExistentIDMutation":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithDatabaseMutation":4,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe":4,"Tests\\Unit\\Config\\DatabaseTest::test_connect_usa_opciones_pdo_correctamente":1,"Tests\\Unit\\Config\\DatabaseTest::test_connect_con_diferentes_opciones_pdo":1,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio":3,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging":4,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_total_negativo":3,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_email_nulo":3,"Tests\\Unit\\Controllers\\UserControllerTest::test_conexion_fallida":3},"times":{"Tests\\Unit\\Controllers\\OrderControllerTest::testCreateOrder":0.009,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetUserOrders":0.003,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetOrders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testUpdatePaymentStatus":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testDeleteOrder":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetAllOrders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetAllProducts":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetAllUsers":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetOrdersWithError":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::testUpdatePaymentStatusWithError":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::testGetProductById":0.014,"Tests\\Unit\\Controllers\\ProductControllerTest::testCreateProduct":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::el_registro_de_usuario_debe_ser_exitoso":0.212,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_ser_exitoso_con_credenciales_correctas":0.104,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_fallar_con_credenciales_incorrectas":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::debe_obtener_usuario_por_id_correctamente":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::user_can_register":0.201,"Tests\\Unit\\Controllers\\UserControllerTest::user_can_login":0.101,"Tests\\Unit\\Controllers\\UserControllerTest::login_fails_with_wrong_credentials":0,"Tests\\Unit\\Controllers\\UserControllerTest::can_get_user_by_id":0,"Tests\\Unit\\Controllers\\ProductControllerTest::get_product_by_id":0.013,"Tests\\Unit\\Controllers\\ProductControllerTest::create_product":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::get_latest_products":0,"Tests\\Unit\\Controllers\\ProductControllerTest::add_to_cart":0,"Tests\\Unit\\Controllers\\ProductControllerTest::get_cart_items":0,"Tests\\Unit\\Controllers\\AdminControllerTest::get_dashboard_data":0.009,"Tests\\Unit\\Controllers\\AdminControllerTest::add_product_success":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::update_order_status":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::get_all_users":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::delete_product":0,"Tests\\Unit\\Controllers\\OrderControllerTest::create_order":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::get_user_orders":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::update_payment_status":0,"Tests\\Unit\\Controllers\\OrderControllerTest::delete_order":0,"Tests\\Unit\\Controllers\\OrderControllerTest::get_all_orders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::handle_database_error_on_get_orders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::handle_database_error_on_update_status":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_success":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_missing_fields":0,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_user_not_found":0,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_already_sent":0,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_save_error":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_throws_exception":0.001,"Tests\\Unit\\Controllers\\SearchControllerTest::search_products_returns_results":0,"Tests\\Unit\\Controllers\\SearchControllerTest::search_products_returns_empty_array_when_no_results":0,"Tests\\Unit\\Controllers\\SearchControllerTest::search_products_returns_empty_array_on_exception":0,"Tests\\Unit\\Controllers\\AdminControllerTest::obtener_datos_dashboard":0.009,"Tests\\Unit\\Controllers\\AdminControllerTest::agregar_producto_exitoso":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::actualizar_estado_pedido":0,"Tests\\Unit\\Controllers\\AdminControllerTest::obtener_todos_usuarios":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::eliminar_producto":0,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_campos_faltantes":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_usuario_no_encontrado":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::actualizar_estado_pago":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::eliminar_pedido":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_actualizar_estado":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes":0.002,"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito":0.002,"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito":0.002,"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados":0.001,"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_no_hay_resultados":0.001,"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_hay_excepcion":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse":0.212,"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion":0.104,"Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id":0.001,"Warning":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData":0.003,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers":0.003,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct":0.002,"Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos":0.002,"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_producto_duplicado_al_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_actualizar_cantidad":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_productos_recientes":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_todos_productos":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_items_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_item_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito":0.002,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito":0.002,"Tests\\Unit\\Controllers\\ProductControllerTest::verificar_carrito_vacio":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_carrito_vacio":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_productos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_usuarios":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login":0.003,"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_al_obtener_usuario":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::registro_con_tipo_usuario_personalizado":0.209,"Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register":0.208,"Tests\\Unit\\Controllers\\UserControllerTest::logout_exitoso":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::verificar_hash_password":0.212,"Tests\\Unit\\Controllers\\ContactControllerTest::crear_usuario_retorna_instancia_user":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters":0.003,"Tests\\Unit\\Controllers\\ContactControllerTest::constructor_asigna_conexion":0.004,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_maneja_error_en_save":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_user_id":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleDatabaseError":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testValidateImageName":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetOrdersCount":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetProductsCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetUsersCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAdminsCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalAccounts":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetMessagesCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithoutImage":0.02,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDelete":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithLargeImage":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProductNotFound":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatusDatabaseError":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrderDatabaseError":0.002,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message":0.001,"Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje":0.001,"Tests\\Unit\\Models\\MessageTest::maneja_error_al_guardar":0.001,"Tests\\Unit\\Models\\MessageTest::verifica_si_mensaje_existe":0.002,"Tests\\Unit\\Models\\MessageTest::verifica_mensaje_no_existente":0.002,"Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia":0.002,"Tests\\Unit\\Config\\DatabaseTest::puede_obtener_conexion":2.725,"Tests\\Unit\\Config\\DatabaseTest::maneja_error_de_conexion":2.706,"Tests\\Unit\\Config\\DatabaseTest::verifica_singleton_pattern":2.706,"Tests\\Unit\\Config\\DatabaseTest::verifica_propiedades_conexion":2.693,"Tests\\Unit\\Config\\DatabaseTest::verifica_charset_conexion":2.692,"Tests\\Unit\\Config\\DatabaseTest::verifica_collation_conexion":2.704,"Tests\\Unit\\Config\\DatabaseTest::verifica_timezone_conexion":2.69,"Tests\\Unit\\Config\\DatabaseTest::verifica_max_connections":2.68,"Tests\\Unit\\Config\\DatabaseTest::constructor_carga_variables_desde_env_file":0.007,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_valores_por_defecto_sin_env":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_lanza_database_exception":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_charset_utf8":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_corrupto":0,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_getenv_cuando_disponible":0,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_atributos_pdo":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_registra_error_antes_de_lanzar_excepcion":0.001,"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_con_parametros":0.001,"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_sin_parametros":0.001,"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::hereda_de_exception":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_no_existente":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_invalido":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_variables_de_entorno":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_establece_conexion_exitosa":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_maneja_error_de_conexion":0.001,"Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type":0.001,"Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado":0.104,"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_true_cuando_existe":0.001,"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_false_cuando_no_existe":0.002,"Tests\\Unit\\Models\\UserTest::verifica_setId_retorna_instancia":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto":0.41,"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_correcto":0.103,"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_incorrecto":0.105,"Tests\\Unit\\Controllers\\UserControllerTest::logout_maneja_error_session_start":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_password_incorrecto":0.104,"Tests\\Unit\\Controllers\\UserControllerTest::login_exitoso_con_admin":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::registro_exitoso_sin_tipo_usuario":0.203,"Tests\\Unit\\Controllers\\UserControllerTest::obtener_usuario_inexistente":0.001,"Tests\\Unit\\Config\\DatabaseTest::verifica_conexion_exitosa":0.006,"Tests\\Unit\\Config\\DatabaseTest::verifica_error_conexion":0.001,"Tests\\Unit\\Config\\DatabaseTest::verifica_valores_por_defecto":0.006,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env":0.002,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_variables_entorno":0.001,"Tests\\Unit\\Config\\DatabaseTest::verifica_manejo_error_conexion":0.055,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env_file":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_logout_limpia_sesion":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_email_existente":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_error_db":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_credenciales_invalidas":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_password_incorrecto":0.104,"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_error_db":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_usuario_no_existe":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_con_error_db":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_id_en_sesion":0.102,"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_nombre_en_sesion":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_tipo_usuario_en_sesion":0.107,"Tests\\Unit\\Controllers\\UserControllerTest::logout_limpia_sesion":0.001,"Tests\\Unit\\IndexTest::redirige_a_admin_si_usuario_es_admin":0,"Tests\\Unit\\IndexTest::redirige_a_home_si_usuario_no_es_admin":0,"Tests\\Unit\\IndexTest::redirige_a_login_si_no_hay_sesion":0,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_valores_por_defecto":0.006,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_carga_variables_entorno":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_lanza_excepcion_con_credenciales_invalidas":0.006,"Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion":2.7,"Tests\\Unit\\AutoloadTest::test_puede_cargar_clase_existente":0.001,"Tests\\Unit\\AutoloadTest::test_maneja_clase_inexistente":0.001,"Tests\\Unit\\Views\\ShopTest::test_redirige_si_no_hay_sesion":0.001,"Tests\\Unit\\Views\\ShopTest::test_puede_obtener_productos":0.001,"Tests\\Unit\\Views\\ShopTest::test_puede_anadir_al_carrito":0.001,"Tests\\Unit\\Views\\ShopTest::test_muestra_mensaje_cuando_no_hay_productos":0.004,"Tests\\UI\\Pages\\ShopPageTest::testVerProductosEnTienda":1.701,"Tests\\UI\\Pages\\ShopPageTest::testAgregarProductoAlCarrito":0.558,"Tests\\UI\\Pages\\LoginPageTest::testLoginPageElements":2.891,"Tests\\UI\\Pages\\LoginPageTest::testLoginAttempt":15.38,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginVisual":8.279,"Tests\\UI\\Pages\\LoginPageTest::testUserLoginVisual":9.974,"Tests\\UI\\Pages\\LoginPageTest::testLoginFailure":6.717,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLogoutVisual":8.053,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginFailure":7.068,"Tests\\UI\\Pages\\RegisterPageTest::testUserRegisterSuccess":9.999,"Tests\\UI\\Pages\\RegisterPageTest::testRegisterFailure":9.157,"Tests\\UI\\Pages\\SearchPageTest::testSearchFunctionality":7.83,"Tests\\UI\\Pages\\SearchPageTest::testEmptySearch":7.912,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearch":7.793,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearchWithResults":9.224,"Tests\\UI\\Pages\\SearchPageTest::testSearchWithNoResults":9.448,"Tests\\UI\\Pages\\ShopPageTest::testShopPageLoadsWithProducts":4.8,"Tests\\UI\\Pages\\ShopPageTest::testAddProductToCart":5.838,"Tests\\UI\\Pages\\ShopPageTest::testAddNewProductToCart":5.055,"Tests\\UI\\Pages\\ShopPageTest::testAddDuplicateProductToCart":4.874,"Tests\\UI\\Pages\\ShopPageTest::testUpdateProductQuantityInCart":4.851,"Tests\\UI\\Pages\\ShopPageTest::testProceedToCheckoutAndPlaceOrder":12.987,"Tests\\UI\\Pages\\ShopPageTest::testViewOrders":5.08,"Tests\\UI\\Pages\\ContactPageTest::testSendContactForm":2.773,"Tests\\UI\\Pages\\AdminProductTest::testAddAndUpdateProduct":12.939,"Tests\\UI\\Pages\\AdminOrderTest::testUpdateOrderStatus":15.191,"Tests\\UI\\Pages\\AdminUsersMessagesTest::testViewUsersAndMessages":8.927,"Tests\\UI\\Pages\\AdminUsersMessagesTest::testViewUsersAndMessagesAndLogout":4.841,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsMutation":0.004,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutation":0.002,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutation":0.001,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithMissingFields":0.001,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithInvalidUserId":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationSuccess":0.002,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutationWithEmptyCart":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusMutation":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testDeleteOrderMutation":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartMutationWithDuplicate":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityMutation":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testDeleteCartItemMutation":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderWithInvalidData":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusWithInvalidData":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityWithInvalidQuantity":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartWithInvalidData":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testGetCartItemsMutation":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testDeleteAllCartItemsMutation":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testGetAllProductsMutation":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testGetLatestProductsMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllOrdersMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithInvalidDataMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllProductsMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllUsersMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductWithInvalidImageMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserMutation":0.002,"Tests\\Mutation\\DatabaseMutationTest::testNullCredentialsMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testInvalidEnvFileMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testEnvCredentialsMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testSetCredentialsMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testEmptyCredentialsMutation":4.113,"Tests\\Mutation\\DatabaseMutationTest::testConnectionFailureMutation":2.693,"Tests\\Mutation\\DatabaseMutationTest::testDefaultCredentialsMutation":0,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithHTMLContentMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyMessageMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithInvalidPhoneNumberMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithNullValuesMutation":0.001,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithXSSAttemptMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithLongMessageMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithInvalidEmailMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithSpecialCharactersMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyNameMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithSQLInjectionAttemptMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithSQLInjectionAttemptMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageWithInvalidIDMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductWithInvalidExtensionMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductWithCascadingEffectMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderWithDatabaseErrorMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusWithInvalidIDMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithMissingImageMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataWithErrorMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllUsersWithEmptyResultMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithZeroResultMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesWithDatabaseErrorMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserWithNonExistentIDMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testHandleDatabaseErrorMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::test_login_con_error_db":0.001,"Tests\\Mutation\\AdminControllerMutationTest::login_exitoso_con_admin":0.104,"Tests\\Mutation\\AdminControllerMutationTest::verifica_hash_password_con_costo_correcto":0.41,"Tests\\Mutation\\AdminControllerMutationTest::login_guarda_tipo_usuario_en_sesion":0.108,"Tests\\Mutation\\AdminControllerMutationTest::test_getUserById_con_error_db":0.001,"Tests\\Mutation\\AdminControllerMutationTest::test_login_con_password_incorrecto":0.103,"Tests\\Mutation\\AdminControllerMutationTest::login_falla_con_password_incorrecto":0.103,"Tests\\Mutation\\AdminControllerMutationTest::test_getUserById_usuario_no_existe":0.001,"Tests\\Mutation\\AdminControllerMutationTest::usuario_puede_registrarse":0.204,"Tests\\Mutation\\AdminControllerMutationTest::puede_obtener_usuario_por_id":0.001,"Tests\\Mutation\\AdminControllerMutationTest::manejo_error_en_login":0.001,"Tests\\Mutation\\AdminControllerMutationTest::test_register_con_error_db":0.001,"Tests\\Mutation\\AdminControllerMutationTest::registro_falla_con_email_existente":0.001,"Tests\\Mutation\\AdminControllerMutationTest::registro_con_tipo_usuario_personalizado":0.204,"Tests\\Mutation\\AdminControllerMutationTest::usuario_puede_iniciar_sesion":0.103,"Tests\\Mutation\\AdminControllerMutationTest::verifica_password_correcto":0.104,"Tests\\Mutation\\AdminControllerMutationTest::test_login_con_credenciales_invalidas":0.001,"Tests\\Mutation\\AdminControllerMutationTest::obtener_usuario_inexistente":0.001,"Tests\\Mutation\\AdminControllerMutationTest::registro_exitoso_sin_tipo_usuario":0.205,"Tests\\Mutation\\AdminControllerMutationTest::verificar_alias_register":0.206,"Tests\\Mutation\\AdminControllerMutationTest::login_guarda_nombre_en_sesion":0.106,"Tests\\Mutation\\AdminControllerMutationTest::verifica_password_incorrecto":0.103,"Tests\\Mutation\\AdminControllerMutationTest::manejo_error_en_registro":0.002,"Tests\\Mutation\\AdminControllerMutationTest::manejo_error_al_obtener_usuario":0.002,"Tests\\Mutation\\AdminControllerMutationTest::inicio_sesion_falla_con_credenciales_incorrectas":0.001,"Tests\\Mutation\\AdminControllerMutationTest::verificar_hash_password":0.203,"Tests\\Mutation\\AdminControllerMutationTest::test_register_con_email_existente":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithDatabaseMutation":0.002,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_set_credentials_establece_valores_correctamente":0,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_valores_por_defecto_cuando_no_hay_env":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_cuando_use_env_es_false":0,"Tests\\Unit\\Config\\DatabaseTest::test_connect_usa_opciones_pdo_correctamente":4.087,"Tests\\Unit\\Config\\DatabaseTest::test_connect_con_diferentes_opciones_pdo":4.1,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio":0.001,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging":0.012,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos_cuando_no_hay_datos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_carrito_items_vacio":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_total_negativo":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_foreach_array_vacio":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_id_nulo":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_email_nulo":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_parametro_vacio":0.004,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_parametros_vacios":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto":0.207,"Tests\\Unit\\Controllers\\UserControllerTest::register_con_tipo_usuario_invalido":0.205,"Tests\\Unit\\Controllers\\UserControllerTest::register_establece_tipo_usuario_correctamente":0.614,"Tests\\Mutation\\AdminControllerMutationTest::dummy_test":0.006,"Tests\\Unit\\Controllers\\UserControllerTest::test_conexion_fallida":0.001}} \ No newline at end of file +{"version":1,"defects":{"Tests\\Unit\\Controllers\\ProductControllerTest::testGetProductById":8,"Tests\\Unit\\Controllers\\ProductControllerTest::testCreateProduct":8,"Tests\\Unit\\Controllers\\UserControllerTest::el_registro_de_usuario_debe_ser_exitoso":8,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_ser_exitoso_con_credenciales_correctas":8,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_fallar_con_credenciales_incorrectas":8,"Tests\\Unit\\Controllers\\UserControllerTest::debe_obtener_usuario_por_id_correctamente":8,"Tests\\Unit\\Controllers\\ProductControllerTest::get_product_by_id":8,"Tests\\Unit\\Controllers\\ProductControllerTest::create_product":8,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_success":7,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_user_not_found":8,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_already_sent":7,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_save_error":7,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_throws_exception":7,"Warning":6,"Tests\\Unit\\Controllers\\UserControllerTest::logout_exitoso":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testValidateImageName":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithLargeImage":4,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProductNotFound":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrderDatabaseError":4,"Tests\\Unit\\Models\\MessageTest::verifica_si_mensaje_existe":3,"Tests\\Unit\\Models\\MessageTest::verifica_mensaje_no_existente":3,"Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia":4,"Tests\\Unit\\Config\\DatabaseTest::puede_obtener_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::maneja_error_de_conexion":3,"Tests\\Unit\\Config\\DatabaseTest::verifica_singleton_pattern":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_propiedades_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_charset_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_collation_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_timezone_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_max_connections":4,"Tests\\Unit\\Config\\DatabaseTest::connect_lanza_database_exception":4,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_charset_utf8":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_corrupto":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_getenv_cuando_disponible":4,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_atributos_pdo":4,"Tests\\Unit\\Config\\DatabaseTest::connect_registra_error_antes_de_lanzar_excepcion":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_carga_variables_desde_env_file":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_valores_por_defecto_sin_env":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_no_existente":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_invalido":4,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_variables_de_entorno":4,"Tests\\Unit\\Config\\DatabaseTest::connect_establece_conexion_exitosa":4,"Tests\\Unit\\Config\\DatabaseTest::connect_maneja_error_de_conexion":4,"Tests\\Unit\\Controllers\\UserControllerTest::logout_maneja_error_session_start":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_conexion_exitosa":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_error_conexion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_valores_por_defecto":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_manejo_error_conexion":4,"Tests\\Unit\\Controllers\\UserControllerTest::test_logout_limpia_sesion":3,"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_usuario_no_existe":3,"Tests\\Unit\\Controllers\\UserControllerTest::logout_limpia_sesion":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_variables_entorno":4,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env_file":4,"Tests\\Unit\\IndexTest::redirige_a_admin_si_usuario_es_admin":4,"Tests\\Unit\\IndexTest::redirige_a_home_si_usuario_no_es_admin":4,"Tests\\Unit\\IndexTest::redirige_a_login_si_no_hay_sesion":4,"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion":3,"Tests\\Unit\\Controllers\\UserControllerTest::login_exitoso_con_admin":3,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_valores_por_defecto":4,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_carga_variables_entorno":4,"Tests\\Unit\\Config\\DatabaseTest::test_lanza_excepcion_con_credenciales_invalidas":4,"Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion":4,"Tests\\Unit\\Views\\ShopTest::test_redirige_si_no_hay_sesion":4,"Tests\\Unit\\Views\\ShopTest::test_puede_obtener_productos":4,"Tests\\UI\\Pages\\ShopPageTest::testVerProductosEnTienda":4,"Tests\\UI\\Pages\\ShopPageTest::testAgregarProductoAlCarrito":4,"Tests\\UI\\Pages\\LoginPageTest::testLoginPageElements":3,"Tests\\UI\\Pages\\LoginPageTest::testLoginAttempt":3,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginVisual":3,"Tests\\UI\\Pages\\LoginPageTest::testUserLoginVisual":3,"Tests\\UI\\Pages\\LoginPageTest::testLoginFailure":3,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLogoutVisual":3,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearch":4,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearchWithResults":4,"Tests\\UI\\Pages\\SearchPageTest::testSearchWithNoResults":4,"Tests\\UI\\Pages\\ShopPageTest::testShopPageLoadsWithProducts":4,"Tests\\UI\\Pages\\ShopPageTest::testAddProductToCart":4,"Tests\\UI\\Pages\\ShopPageTest::testAddNewProductToCart":3,"Tests\\UI\\Pages\\ShopPageTest::testProceedToCheckoutAndPlaceOrder":3,"Tests\\UI\\Pages\\ShopPageTest::testViewOrders":3,"Tests\\UI\\Pages\\ShopPageTest::testUpdateProductQuantityInCart":3,"Tests\\UI\\Pages\\ContactPageTest::testSendContactForm":4,"Tests\\UI\\Pages\\AdminProductTest::testAddAndUpdateProduct":4,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginFailure":3,"Tests\\UI\\Pages\\AdminOrderTest::testUpdateOrderStatus":4,"Tests\\UI\\Pages\\AdminUsersMessagesTest::testViewUsersAndMessagesAndLogout":3,"Tests\\UI\\Pages\\RegisterPageTest::testUserRegisterSuccess":3,"Tests\\UI\\Pages\\ShopPageTest::testAddDuplicateProductToCart":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductMutation":3,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutation":3,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutation":4,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationSuccess":3,"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusMutation":3,"Tests\\Mutation\\OrderControllerMutationTest::testDeleteOrderMutation":3,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityMutation":3,"Tests\\Mutation\\ProductControllerMutationTest::testDeleteCartItemMutation":3,"Tests\\Unit\\AutoloadTest::test_puede_cargar_clase_existente":1,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityWithInvalidQuantity":3,"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartWithInvalidData":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllOrdersMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllProductsMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllUsersMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserMutation":3,"Tests\\Mutation\\DatabaseMutationTest::testInvalidEnvFileMutation":4,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyMessageMutation":3,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyNameMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithSQLInjectionAttemptMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageWithInvalidIDMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductWithInvalidExtensionMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderWithDatabaseErrorMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusWithInvalidIDMutation":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataWithErrorMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithZeroResultMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesWithDatabaseErrorMutation":4,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserWithNonExistentIDMutation":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings":3,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithDatabaseMutation":4,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe":4,"Tests\\Unit\\Config\\DatabaseTest::test_connect_usa_opciones_pdo_correctamente":1,"Tests\\Unit\\Config\\DatabaseTest::test_connect_con_diferentes_opciones_pdo":1,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio":3,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging":4,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_total_negativo":3,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_email_nulo":3,"Tests\\Unit\\Controllers\\UserControllerTest::test_conexion_fallida":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathExtensionCaseSensitive":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithInvalidPrice":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithCorruptedImage":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithMaximumNameLength":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithInvalidImageType":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithMissingData":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithSpecialCharactersInName":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithMissingImage":3,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithDatabaseError":4,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProductWithEmptyExecuteParams":3,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_datos_invalidos":3,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_invalido":3,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_vacio":3},"times":{"Tests\\Unit\\Controllers\\OrderControllerTest::testCreateOrder":0.009,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetUserOrders":0.003,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetOrders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testUpdatePaymentStatus":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testDeleteOrder":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetAllOrders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetAllProducts":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetAllUsers":0,"Tests\\Unit\\Controllers\\OrderControllerTest::testGetOrdersWithError":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::testUpdatePaymentStatusWithError":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::testGetProductById":0.014,"Tests\\Unit\\Controllers\\ProductControllerTest::testCreateProduct":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::el_registro_de_usuario_debe_ser_exitoso":0.212,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_ser_exitoso_con_credenciales_correctas":0.104,"Tests\\Unit\\Controllers\\UserControllerTest::el_login_debe_fallar_con_credenciales_incorrectas":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::debe_obtener_usuario_por_id_correctamente":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::user_can_register":0.201,"Tests\\Unit\\Controllers\\UserControllerTest::user_can_login":0.101,"Tests\\Unit\\Controllers\\UserControllerTest::login_fails_with_wrong_credentials":0,"Tests\\Unit\\Controllers\\UserControllerTest::can_get_user_by_id":0,"Tests\\Unit\\Controllers\\ProductControllerTest::get_product_by_id":0.013,"Tests\\Unit\\Controllers\\ProductControllerTest::create_product":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::get_latest_products":0,"Tests\\Unit\\Controllers\\ProductControllerTest::add_to_cart":0,"Tests\\Unit\\Controllers\\ProductControllerTest::get_cart_items":0,"Tests\\Unit\\Controllers\\AdminControllerTest::get_dashboard_data":0.009,"Tests\\Unit\\Controllers\\AdminControllerTest::add_product_success":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::update_order_status":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::get_all_users":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::delete_product":0,"Tests\\Unit\\Controllers\\OrderControllerTest::create_order":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::get_user_orders":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::update_payment_status":0,"Tests\\Unit\\Controllers\\OrderControllerTest::delete_order":0,"Tests\\Unit\\Controllers\\OrderControllerTest::get_all_orders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::handle_database_error_on_get_orders":0,"Tests\\Unit\\Controllers\\OrderControllerTest::handle_database_error_on_update_status":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_success":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_missing_fields":0,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_user_not_found":0,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_already_sent":0,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_save_error":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::send_message_throws_exception":0.001,"Tests\\Unit\\Controllers\\SearchControllerTest::search_products_returns_results":0,"Tests\\Unit\\Controllers\\SearchControllerTest::search_products_returns_empty_array_when_no_results":0,"Tests\\Unit\\Controllers\\SearchControllerTest::search_products_returns_empty_array_on_exception":0,"Tests\\Unit\\Controllers\\AdminControllerTest::obtener_datos_dashboard":0.009,"Tests\\Unit\\Controllers\\AdminControllerTest::agregar_producto_exitoso":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::actualizar_estado_pedido":0,"Tests\\Unit\\Controllers\\AdminControllerTest::obtener_todos_usuarios":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::eliminar_producto":0,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_campos_faltantes":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_usuario_no_encontrado":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::actualizar_estado_pago":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::eliminar_pedido":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_actualizar_estado":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito":0.002,"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados":0.002,"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_no_hay_resultados":0.002,"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_hay_excepcion":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse":0.209,"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id":0.002,"Warning":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData":0.003,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_producto_duplicado_al_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_actualizar_cantidad":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_productos_recientes":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_todos_productos":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_items_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_item_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito":0.001,"Tests\\Unit\\Controllers\\ProductControllerTest::verificar_carrito_vacio":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_carrito_vacio":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_productos":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_usuarios":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_al_obtener_usuario":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::registro_con_tipo_usuario_personalizado":0.21,"Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register":0.21,"Tests\\Unit\\Controllers\\UserControllerTest::logout_exitoso":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::verificar_hash_password":0.209,"Tests\\Unit\\Controllers\\ContactControllerTest::crear_usuario_retorna_instancia_user":0.004,"Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters":0.003,"Tests\\Unit\\Controllers\\ContactControllerTest::constructor_asigna_conexion":0.001,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_maneja_error_en_save":0.002,"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_user_id":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleDatabaseError":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testValidateImageName":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetOrdersCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetProductsCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetUsersCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAdminsCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalAccounts":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetMessagesCount":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithoutImage":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDelete":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithLargeImage":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProductNotFound":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatusDatabaseError":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrderDatabaseError":0.002,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number":0.001,"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message":0.001,"Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje":0.001,"Tests\\Unit\\Models\\MessageTest::maneja_error_al_guardar":0.002,"Tests\\Unit\\Models\\MessageTest::verifica_si_mensaje_existe":0.002,"Tests\\Unit\\Models\\MessageTest::verifica_mensaje_no_existente":0.002,"Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia":0.002,"Tests\\Unit\\Config\\DatabaseTest::puede_obtener_conexion":2.725,"Tests\\Unit\\Config\\DatabaseTest::maneja_error_de_conexion":2.706,"Tests\\Unit\\Config\\DatabaseTest::verifica_singleton_pattern":2.706,"Tests\\Unit\\Config\\DatabaseTest::verifica_propiedades_conexion":2.693,"Tests\\Unit\\Config\\DatabaseTest::verifica_charset_conexion":2.692,"Tests\\Unit\\Config\\DatabaseTest::verifica_collation_conexion":2.704,"Tests\\Unit\\Config\\DatabaseTest::verifica_timezone_conexion":2.69,"Tests\\Unit\\Config\\DatabaseTest::verifica_max_connections":2.68,"Tests\\Unit\\Config\\DatabaseTest::constructor_carga_variables_desde_env_file":0.007,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_valores_por_defecto_sin_env":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_lanza_database_exception":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_charset_utf8":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_corrupto":0,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_getenv_cuando_disponible":0,"Tests\\Unit\\Config\\DatabaseTest::connect_configura_atributos_pdo":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_registra_error_antes_de_lanzar_excepcion":0.001,"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_con_parametros":0.001,"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_sin_parametros":0.002,"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::hereda_de_exception":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_no_existente":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_maneja_env_file_invalido":0.001,"Tests\\Unit\\Config\\DatabaseTest::constructor_usa_variables_de_entorno":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_establece_conexion_exitosa":0.001,"Tests\\Unit\\Config\\DatabaseTest::connect_maneja_error_de_conexion":0.001,"Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type":0.001,"Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado":0.107,"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_true_cuando_existe":0.001,"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_false_cuando_no_existe":0.001,"Tests\\Unit\\Models\\UserTest::verifica_setId_retorna_instancia":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto":0.431,"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_correcto":0.105,"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_incorrecto":0.105,"Tests\\Unit\\Controllers\\UserControllerTest::logout_maneja_error_session_start":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_password_incorrecto":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::login_exitoso_con_admin":0.107,"Tests\\Unit\\Controllers\\UserControllerTest::registro_exitoso_sin_tipo_usuario":0.215,"Tests\\Unit\\Controllers\\UserControllerTest::obtener_usuario_inexistente":0.001,"Tests\\Unit\\Config\\DatabaseTest::verifica_conexion_exitosa":0.006,"Tests\\Unit\\Config\\DatabaseTest::verifica_error_conexion":0.001,"Tests\\Unit\\Config\\DatabaseTest::verifica_valores_por_defecto":0.006,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env":0.002,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_variables_entorno":0.001,"Tests\\Unit\\Config\\DatabaseTest::verifica_manejo_error_conexion":0.055,"Tests\\Unit\\Config\\DatabaseTest::verifica_carga_env_file":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_logout_limpia_sesion":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_email_existente":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_error_db":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_credenciales_invalidas":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_password_incorrecto":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_error_db":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_usuario_no_existe":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_con_error_db":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_id_en_sesion":0.102,"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_nombre_en_sesion":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_tipo_usuario_en_sesion":0.106,"Tests\\Unit\\Controllers\\UserControllerTest::logout_limpia_sesion":0.001,"Tests\\Unit\\IndexTest::redirige_a_admin_si_usuario_es_admin":0,"Tests\\Unit\\IndexTest::redirige_a_home_si_usuario_no_es_admin":0,"Tests\\Unit\\IndexTest::redirige_a_login_si_no_hay_sesion":0,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_valores_por_defecto":0.006,"Tests\\Unit\\Config\\DatabaseTest::test_verifica_carga_variables_entorno":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_lanza_excepcion_con_credenciales_invalidas":0.006,"Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion":2.701,"Tests\\Unit\\AutoloadTest::test_puede_cargar_clase_existente":0.002,"Tests\\Unit\\AutoloadTest::test_maneja_clase_inexistente":0.001,"Tests\\Unit\\Views\\ShopTest::test_redirige_si_no_hay_sesion":0.001,"Tests\\Unit\\Views\\ShopTest::test_puede_obtener_productos":0.002,"Tests\\Unit\\Views\\ShopTest::test_puede_anadir_al_carrito":0.001,"Tests\\Unit\\Views\\ShopTest::test_muestra_mensaje_cuando_no_hay_productos":0.006,"Tests\\UI\\Pages\\ShopPageTest::testVerProductosEnTienda":1.701,"Tests\\UI\\Pages\\ShopPageTest::testAgregarProductoAlCarrito":0.558,"Tests\\UI\\Pages\\LoginPageTest::testLoginPageElements":2.891,"Tests\\UI\\Pages\\LoginPageTest::testLoginAttempt":15.38,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginVisual":8.279,"Tests\\UI\\Pages\\LoginPageTest::testUserLoginVisual":9.974,"Tests\\UI\\Pages\\LoginPageTest::testLoginFailure":6.717,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLogoutVisual":8.053,"Tests\\UI\\Pages\\AdminLoginTest::testAdminLoginFailure":7.068,"Tests\\UI\\Pages\\RegisterPageTest::testUserRegisterSuccess":9.999,"Tests\\UI\\Pages\\RegisterPageTest::testRegisterFailure":9.157,"Tests\\UI\\Pages\\SearchPageTest::testSearchFunctionality":7.83,"Tests\\UI\\Pages\\SearchPageTest::testEmptySearch":7.912,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearch":7.793,"Tests\\UI\\Pages\\SearchPageTest::testAddToCartFromSearchWithResults":9.224,"Tests\\UI\\Pages\\SearchPageTest::testSearchWithNoResults":9.448,"Tests\\UI\\Pages\\ShopPageTest::testShopPageLoadsWithProducts":4.8,"Tests\\UI\\Pages\\ShopPageTest::testAddProductToCart":5.838,"Tests\\UI\\Pages\\ShopPageTest::testAddNewProductToCart":5.055,"Tests\\UI\\Pages\\ShopPageTest::testAddDuplicateProductToCart":4.874,"Tests\\UI\\Pages\\ShopPageTest::testUpdateProductQuantityInCart":4.851,"Tests\\UI\\Pages\\ShopPageTest::testProceedToCheckoutAndPlaceOrder":12.987,"Tests\\UI\\Pages\\ShopPageTest::testViewOrders":5.08,"Tests\\UI\\Pages\\ContactPageTest::testSendContactForm":2.773,"Tests\\UI\\Pages\\AdminProductTest::testAddAndUpdateProduct":12.939,"Tests\\UI\\Pages\\AdminOrderTest::testUpdateOrderStatus":15.191,"Tests\\UI\\Pages\\AdminUsersMessagesTest::testViewUsersAndMessages":8.927,"Tests\\UI\\Pages\\AdminUsersMessagesTest::testViewUsersAndMessagesAndLogout":4.841,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsMutation":0.004,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutation":0.002,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutation":0.001,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithMissingFields":0.001,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithInvalidUserId":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationSuccess":0.002,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutationWithEmptyCart":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusMutation":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testDeleteOrderMutation":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartMutationWithDuplicate":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityMutation":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testDeleteCartItemMutation":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderWithInvalidData":0.001,"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusWithInvalidData":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityWithInvalidQuantity":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartWithInvalidData":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testGetCartItemsMutation":0.002,"Tests\\Mutation\\ProductControllerMutationTest::testDeleteAllCartItemsMutation":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testGetAllProductsMutation":0.001,"Tests\\Mutation\\ProductControllerMutationTest::testGetLatestProductsMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllOrdersMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithInvalidDataMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllProductsMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllUsersMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductWithInvalidImageMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserMutation":0.002,"Tests\\Mutation\\DatabaseMutationTest::testNullCredentialsMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testInvalidEnvFileMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testEnvCredentialsMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testSetCredentialsMutation":0.001,"Tests\\Mutation\\DatabaseMutationTest::testEmptyCredentialsMutation":4.113,"Tests\\Mutation\\DatabaseMutationTest::testConnectionFailureMutation":2.693,"Tests\\Mutation\\DatabaseMutationTest::testDefaultCredentialsMutation":0,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithHTMLContentMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyMessageMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithInvalidPhoneNumberMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithNullValuesMutation":0.001,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithXSSAttemptMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithLongMessageMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithInvalidEmailMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithSpecialCharactersMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithEmptyNameMutation":0.002,"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageWithSQLInjectionAttemptMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithSQLInjectionAttemptMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteMessageWithInvalidIDMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testAddProductWithInvalidExtensionMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductWithCascadingEffectMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteOrderWithDatabaseErrorMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateOrderStatusWithInvalidIDMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductWithMissingImageMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetDashboardDataWithErrorMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllUsersWithEmptyResultMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithZeroResultMutation":0.003,"Tests\\Mutation\\AdminControllerMutationTest::testGetAllMessagesWithDatabaseErrorMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::testDeleteUserWithNonExistentIDMutation":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testHandleDatabaseErrorMutation":0.002,"Tests\\Mutation\\AdminControllerMutationTest::test_login_con_error_db":0.001,"Tests\\Mutation\\AdminControllerMutationTest::login_exitoso_con_admin":0.104,"Tests\\Mutation\\AdminControllerMutationTest::verifica_hash_password_con_costo_correcto":0.41,"Tests\\Mutation\\AdminControllerMutationTest::login_guarda_tipo_usuario_en_sesion":0.108,"Tests\\Mutation\\AdminControllerMutationTest::test_getUserById_con_error_db":0.001,"Tests\\Mutation\\AdminControllerMutationTest::test_login_con_password_incorrecto":0.103,"Tests\\Mutation\\AdminControllerMutationTest::login_falla_con_password_incorrecto":0.103,"Tests\\Mutation\\AdminControllerMutationTest::test_getUserById_usuario_no_existe":0.001,"Tests\\Mutation\\AdminControllerMutationTest::usuario_puede_registrarse":0.204,"Tests\\Mutation\\AdminControllerMutationTest::puede_obtener_usuario_por_id":0.001,"Tests\\Mutation\\AdminControllerMutationTest::manejo_error_en_login":0.001,"Tests\\Mutation\\AdminControllerMutationTest::test_register_con_error_db":0.001,"Tests\\Mutation\\AdminControllerMutationTest::registro_falla_con_email_existente":0.001,"Tests\\Mutation\\AdminControllerMutationTest::registro_con_tipo_usuario_personalizado":0.204,"Tests\\Mutation\\AdminControllerMutationTest::usuario_puede_iniciar_sesion":0.103,"Tests\\Mutation\\AdminControllerMutationTest::verifica_password_correcto":0.104,"Tests\\Mutation\\AdminControllerMutationTest::test_login_con_credenciales_invalidas":0.001,"Tests\\Mutation\\AdminControllerMutationTest::obtener_usuario_inexistente":0.001,"Tests\\Mutation\\AdminControllerMutationTest::registro_exitoso_sin_tipo_usuario":0.205,"Tests\\Mutation\\AdminControllerMutationTest::verificar_alias_register":0.206,"Tests\\Mutation\\AdminControllerMutationTest::login_guarda_nombre_en_sesion":0.106,"Tests\\Mutation\\AdminControllerMutationTest::verifica_password_incorrecto":0.103,"Tests\\Mutation\\AdminControllerMutationTest::manejo_error_en_registro":0.002,"Tests\\Mutation\\AdminControllerMutationTest::manejo_error_al_obtener_usuario":0.002,"Tests\\Mutation\\AdminControllerMutationTest::inicio_sesion_falla_con_credenciales_incorrectas":0.001,"Tests\\Mutation\\AdminControllerMutationTest::verificar_hash_password":0.203,"Tests\\Mutation\\AdminControllerMutationTest::test_register_con_email_existente":0.001,"Tests\\Mutation\\AdminControllerMutationTest::testGetTotalPendingsWithDatabaseMutation":0.002,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_set_credentials_establece_valores_correctamente":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_valores_por_defecto_cuando_no_hay_env":0.001,"Tests\\Unit\\Config\\DatabaseTest::test_constructor_cuando_use_env_es_false":0,"Tests\\Unit\\Config\\DatabaseTest::test_connect_usa_opciones_pdo_correctamente":4.095,"Tests\\Unit\\Config\\DatabaseTest::test_connect_con_diferentes_opciones_pdo":4.1,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio":0.026,"Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging":0.012,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos_cuando_no_hay_datos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_carrito_items_vacio":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_total_negativo":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_foreach_array_vacio":0.001,"Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_id_nulo":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_email_nulo":0.003,"Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_parametro_vacio":0.002,"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_parametros_vacios":0.004,"Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto":0.21,"Tests\\Unit\\Controllers\\UserControllerTest::register_con_tipo_usuario_invalido":0.21,"Tests\\Unit\\Controllers\\UserControllerTest::register_establece_tipo_usuario_correctamente":0.618,"Tests\\Mutation\\AdminControllerMutationTest::dummy_test":0.006,"Tests\\Unit\\Controllers\\UserControllerTest::test_conexion_fallida":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathWithEmptyAndNonStringName":0.003,"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathExtensionCaseSensitive":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithInvalidPrice":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithCorruptedImage":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithValidData":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithMaximumNameLength":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithInvalidImageType":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithMissingData":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithSpecialCharactersInName":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithMissingImage":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithDatabaseError":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProductWithEmptyExecuteParams":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos_con_datos_nulos":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_datos_parcialmente_nulos":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_datos_invalidos":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario_cuando_estan_vacios":0.002,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_invalido":0.016,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_foreach_vacio":0.001,"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_vacio":0.001,"Tests\\Unit\\Controllers\\AdminControllerTest::obtener_total_pendientes_exitoso":0.002,"Tests\\Unit\\Controllers\\AdminControllerTest::obtener_total_pendientes_maneja_error_execute":0.002}} \ No newline at end of file diff --git a/coverage/clover.xml b/coverage/clover.xml index 4bc602ce..0febc535 100644 --- a/coverage/clover.xml +++ b/coverage/clover.xml @@ -1,6 +1,6 @@ - - + + @@ -49,11 +49,11 @@ - + - - + + @@ -65,168 +65,166 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + - + + + - - - + + - - - - - - - + + + + + + - - + + + + - + - - + - - + - - - + + + + - - - - - - - - - + + + + + + + + - + + - - - + @@ -240,52 +238,52 @@ + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - + + + + + + + @@ -293,18 +291,22 @@ + - - - - - - - - - - - + + + + + + + + + + + + + + @@ -345,13 +347,13 @@ - + - - + + @@ -386,137 +388,142 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + - - + + - + + - - - - - - - - + + + + + + + + + - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + + + + - - - - - + + - - - + + + + + + + + + + + + @@ -765,29 +772,29 @@ - - + + - - - - - + + + + + - - - - - - - - + + + + + + + + - - - + + + @@ -850,6 +857,6 @@ - + diff --git a/coverage/html/Config/Database.php.html b/coverage/html/Config/Database.php.html index 093beb9b..351957fa 100644 --- a/coverage/html/Config/Database.php.html +++ b/coverage/html/Config/Database.php.html @@ -207,9 +207,9 @@ 11    private $database; 12 13    public function __construct(bool $useEnv = true) { - 14        if (!$useEnv) { - 15            $this->setDefaultCredentials(); - 16            return; + 14        if (!$useEnv) { + 15            $this->setDefaultCredentials(); + 16            return; 17        } 18 19        $envPath = __DIR__ . '/../../.env'; @@ -230,18 +230,18 @@ 34 35    private function setDefaultCredentials(): void 36    { - 37        $this->host = getenv('DB_HOST') ?: 'db'; - 38        $this->user = getenv('DB_USER') ?: 'root'; - 39        $this->password = getenv('DB_PASSWORD') ?: '123456'; - 40        $this->database = getenv('DB_NAME') ?: 'tienda_bd'; + 37        $this->host = getenv('DB_HOST') ?: 'db'; + 38        $this->user = getenv('DB_USER') ?: 'root'; + 39        $this->password = getenv('DB_PASSWORD') ?: '123456'; + 40        $this->database = getenv('DB_NAME') ?: 'tienda_bd'; 41    } 42 43    public function setCredentials(string $host, string $user, string $password, string $database): void 44    { - 45        $this->host = $host; - 46        $this->user = $user; - 47        $this->password = $password; - 48        $this->database = $database; + 45        $this->host = $host; + 46        $this->user = $user; + 47        $this->password = $password; + 48        $this->database = $database; 49    } 50 51    public function connect() { @@ -274,7 +274,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Config/dashboard.html b/coverage/html/Config/dashboard.html index 8a210b18..02f2414d 100644 --- a/coverage/html/Config/dashboard.html +++ b/coverage/html/Config/dashboard.html @@ -142,7 +142,7 @@

Project Risks

diff --git a/coverage/html/Config/index.html b/coverage/html/Config/index.html index 99c747b2..d10273b4 100644 --- a/coverage/html/Config/index.html +++ b/coverage/html/Config/index.html @@ -111,7 +111,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/AdminController.php.html b/coverage/html/Controllers/AdminController.php.html index 34a24700..14e47e3e 100644 --- a/coverage/html/Controllers/AdminController.php.html +++ b/coverage/html/Controllers/AdminController.php.html @@ -45,13 +45,13 @@ Total
-
- 83.33% covered (warning) +
+ 84.35% covered (warning)
-
83.33%
-
190 / 228
+
84.35%
+
194 / 230
52.00% covered (warning) @@ -74,13 +74,13 @@ AdminController
-
- 83.26% covered (warning) +
+ 84.28% covered (warning)
-
83.26%
-
189 / 227
+
84.28%
+
193 / 229
52.00% covered (warning) @@ -89,7 +89,7 @@
52.00%
13 / 25
- 80.03 + 78.42
0.00% covered (danger) @@ -153,7 +153,7 @@
100.00%
-
9 / 9
+
11 / 11
100.00% covered (success) @@ -162,12 +162,12 @@
100.00%
1 / 1
- 2 + 3 -  getTotalCompleted +  getTotalCompleted
100.00% covered (success) @@ -189,7 +189,7 @@ -  getOrdersCount +  getOrdersCount
100.00% covered (success) @@ -211,7 +211,7 @@ -  getProductsCount +  getProductsCount
100.00% covered (success) @@ -233,7 +233,7 @@ -  getUsersCount +  getUsersCount
100.00% covered (success) @@ -255,7 +255,7 @@ -  getAdminsCount +  getAdminsCount
100.00% covered (success) @@ -277,7 +277,7 @@ -  getTotalAccounts +  getTotalAccounts
100.00% covered (success) @@ -299,7 +299,7 @@ -  getMessagesCount +  getMessagesCount
100.00% covered (success) @@ -321,7 +321,7 @@ -  handleDatabaseError +  handleDatabaseError
100.00% covered (success) @@ -343,7 +343,7 @@ -  addProduct +  addProduct
76.47% covered (warning) @@ -365,15 +365,15 @@ -  deleteProduct +  deleteProduct
-
- 69.23% covered (warning) +
+ 76.92% covered (warning)
-
69.23%
-
9 / 13
+
76.92%
+
10 / 13
0.00% covered (danger) @@ -382,12 +382,12 @@
0.00%
0 / 1
- 5.73 + 5.31 -  validateImageName +  validateImageName
0.00% covered (danger) @@ -409,15 +409,15 @@ -  getSecureImagePath -
-
- 84.62% covered (warning) +  getSecureImagePath +
+
+ 92.31% covered (success)
-
84.62%
-
11 / 13
+
92.31%
+
12 / 13
0.00% covered (danger) @@ -426,12 +426,12 @@
0.00%
0 / 1
- 6.13 + 6.02 -  handleImageDelete +  handleImageDelete
64.71% covered (warning) @@ -453,7 +453,7 @@ -  updateProduct +  updateProduct
88.46% covered (warning) @@ -475,7 +475,7 @@ -  getAllProducts +  getAllProducts
100.00% covered (success) @@ -497,7 +497,7 @@ -  getAllOrders +  getAllOrders
100.00% covered (success) @@ -519,7 +519,7 @@ -  updateOrderStatus +  updateOrderStatus
62.50% covered (warning) @@ -541,7 +541,7 @@ -  deleteOrder +  deleteOrder
57.14% covered (warning) @@ -563,7 +563,7 @@ -  getAllUsers +  getAllUsers
78.57% covered (warning) @@ -585,7 +585,7 @@ -  deleteUser +  deleteUser
57.14% covered (warning) @@ -607,7 +607,7 @@ -  getAllMessages +  getAllMessages
80.00% covered (warning) @@ -629,7 +629,7 @@ -  deleteMessage +  deleteMessage
50.00% covered (danger) @@ -659,7 +659,7 @@ 1<?php 2namespace Controllers; 3 - 4require_once __DIR__ . '/../autoload.php'; + 4require_once __DIR__ . '/../autoload.php'; 5 6use Models\Product; 7use Models\Order; @@ -672,7 +672,7 @@ 14    private $conn; 15 16    public function __construct($conn) { - 17        $this->conn = $conn; + 17        $this->conn = $conn; 18    } 19 20    public function getDashboardData() { @@ -691,378 +691,382 @@ 33        return $data; 34    } 35 - 36    private function getTotalPendings() { - 37        $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'pendiente'"); - 38        $stmt->execute(); - 39        $total = 0; - 40        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 41            $order = new Order(); - 42            $order->setId($row['id']); - 43            $order->setTotalPrice($row['total_price']); - 44            $total += $order->getTotalPrice(); - 45        } - 46        return $total; - 47    } - 48 - 49    private function getTotalCompleted() { - 50        $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'completado'"); - 51        $stmt->execute(); - 52        $total = 0; - 53        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 54            $order = new Order(); - 55            $order->setId($row['id']); - 56            $order->setTotalPrice($row['total_price']); - 57            $total += $order->getTotalPrice(); - 58        } - 59        return $total; - 60    } - 61 - 62    private function getOrdersCount() { - 63        $query = "SELECT COUNT(*) as count FROM `orders`"; - 64        $stmt = $this->conn->prepare($query); - 65        $stmt->execute(); - 66        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - 67    } - 68 - 69    private function getProductsCount() { - 70        $query = "SELECT COUNT(*) as count FROM `products`"; - 71        $stmt = $this->conn->prepare($query); - 72        $stmt->execute(); - 73        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - 74    } - 75 - 76    private function getUsersCount() { - 77        $query = "SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'"; - 78        $stmt = $this->conn->prepare($query); - 79        $stmt->execute(); - 80        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - 81    } - 82 - 83    private function getAdminsCount() { - 84        $query = "SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'"; - 85        $stmt = $this->conn->prepare($query); - 86        $stmt->execute(); - 87        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - 88    } - 89 - 90    private function getTotalAccounts() { - 91        $query = "SELECT COUNT(*) as count FROM `users`"; - 92        $stmt = $this->conn->prepare($query); - 93        $stmt->execute(); - 94        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - 95    } - 96 - 97    private function getMessagesCount() { - 98        $query = "SELECT COUNT(*) as count FROM `message`"; - 99        $stmt = $this->conn->prepare($query); - 100        $stmt->execute(); - 101        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - 102    } - 103 - 104    private function handleDatabaseError($e) { - 105        error_log("Error en la base de datos: " . $e->getMessage()); - 106        throw new \Exception("Error al procesar la solicitud"); - 107    } - 108 - 109    public function addProduct($postData, $files) { - 110        try { - 111            $product = new Product(); - 112            $product->setName($postData['name']); - 113            $product->setPrice($postData['price']); - 114            $product->setImage($files['image']['name']); - 115 - 116            // Verificar si el producto ya existe - 117            $stmt = $this->conn->prepare("SELECT name FROM `products` WHERE name = ?"); - 118            $stmt->execute([$product->getName()]); - 119             - 120            if($stmt->rowCount() > 0) { - 121                return ['success' => false, 'message' => 'El producto ya existe']; - 122            } - 123 - 124            if($files['image']['size'] > 2000000) { - 125                return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; + 36    public function getTotalPendings() { + 37        try { + 38            $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'pendiente'"); + 39            $stmt->execute(); + 40            $total = 0; + 41            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 42                $order = new Order(); + 43                $order->setId($row['id']); + 44                $order->setTotalPrice($row['total_price']); + 45                $total += $order->getTotalPrice(); + 46            } + 47            return $total; + 48        } catch (\Exception $e) { + 49            $this->handleDatabaseError($e); + 50        } + 51    } + 52 + 53    private function getTotalCompleted() { + 54        $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'completado'"); + 55        $stmt->execute(); + 56        $total = 0; + 57        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 58            $order = new Order(); + 59            $order->setId($row['id']); + 60            $order->setTotalPrice($row['total_price']); + 61            $total += $order->getTotalPrice(); + 62        } + 63        return $total; + 64    } + 65 + 66    private function getOrdersCount() { + 67        $query = "SELECT COUNT(*) as count FROM `orders`"; + 68        $stmt = $this->conn->prepare($query); + 69        $stmt->execute(); + 70        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; + 71    } + 72 + 73    private function getProductsCount() { + 74        $query = "SELECT COUNT(*) as count FROM `products`"; + 75        $stmt = $this->conn->prepare($query); + 76        $stmt->execute(); + 77        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; + 78    } + 79 + 80    private function getUsersCount() { + 81        $query = "SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'"; + 82        $stmt = $this->conn->prepare($query); + 83        $stmt->execute(); + 84        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; + 85    } + 86 + 87    private function getAdminsCount() { + 88        $query = "SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'"; + 89        $stmt = $this->conn->prepare($query); + 90        $stmt->execute(); + 91        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; + 92    } + 93 + 94    private function getTotalAccounts() { + 95        $query = "SELECT COUNT(*) as count FROM `users`"; + 96        $stmt = $this->conn->prepare($query); + 97        $stmt->execute(); + 98        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; + 99    } + 100 + 101    private function getMessagesCount() { + 102        $query = "SELECT COUNT(*) as count FROM `message`"; + 103        $stmt = $this->conn->prepare($query); + 104        $stmt->execute(); + 105        return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; + 106    } + 107 + 108    private function handleDatabaseError($e) { + 109        error_log("Error en la base de datos: " . $e->getMessage()); + 110        throw new \Exception("Error al procesar la solicitud"); + 111    } + 112 + 113    public function addProduct($postData, $files) { + 114        try { + 115            $product = new Product(); + 116            $product->setName($postData['name']); + 117            $product->setPrice($postData['price']); + 118            $product->setImage($files['image']['name']); + 119 + 120            // Verificar si el producto ya existe + 121            $stmt = $this->conn->prepare("SELECT name FROM `products` WHERE name = ?"); + 122            $stmt->execute([$product->getName()]); + 123             + 124            if($stmt->rowCount() > 0) { + 125                return ['success' => false, 'message' => 'El producto ya existe']; 126            } 127 - 128            $stmt = $this->conn->prepare("INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)"); - 129            if($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) { - 130                move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage()); - 131                return ['success' => true, 'message' => '¡Producto añadido exitosamente!']; - 132            } - 133        } catch (\Exception $e) { - 134            $this->handleDatabaseError($e); - 135            return ['success' => false, 'message' => 'Error al añadir el producto']; - 136        } - 137    } - 138 - 139    public function deleteProduct($id) { - 140        try { - 141            // Obtener información de la imagen - 142            $stmt = $this->conn->prepare("SELECT image FROM `products` WHERE id = ?"); - 143            $stmt->execute([$id]); - 144            $image_data = $stmt->fetch(\PDO::FETCH_ASSOC); - 145             - 146            if($image_data) { - 147                $imagePath = self::UPLOAD_PATH . $image_data['image']; - 148                if(file_exists($imagePath)) { - 149                    unlink($imagePath); - 150                } - 151            } - 152             - 153            $stmt = $this->conn->prepare("DELETE FROM `products` WHERE id = ?"); - 154            if($stmt->execute([$id])) { - 155                return ['success' => true, 'message' => 'Producto eliminado']; - 156            } - 157             - 158            return ['success' => false, 'message' => 'Error al eliminar el producto']; - 159        } catch (\Exception $e) { - 160            return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()]; - 161        } - 162    } - 163 - 164    private function validateImageName($imageName) { - 165        // Solo permitir letras, números, guiones y puntos - 166        return preg_match('/^[a-zA-Z0-9_.-]+$/', $imageName); - 167    } - 168 - 169    private function getSecureImagePath($imageName) { - 170        try { - 171            // Validar el nombre del archivo - 172            if (empty($imageName) || !is_string($imageName)) { - 173                throw new \Exception('Nombre de archivo inválido'); - 174            } - 175 - 176            // Obtener y validar la extensión - 177            $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION)); - 178            if (!in_array($extension, self::ALLOWED_EXTENSIONS)) { - 179                throw new \Exception('Tipo de archivo no permitido'); - 180            } - 181 - 182            // Verificar que el archivo existe en la base de datos - 183            $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ?"); - 184            $stmt->execute([$imageName]); - 185            if (!$stmt->fetch()) { - 186                throw new \Exception('Archivo no encontrado en la base de datos'); - 187            } - 188 - 189            return self::UPLOAD_PATH . $imageName; - 190        } catch (\Exception $e) { - 191            error_log("Error en getSecureImagePath: " . $e->getMessage()); - 192            return false; - 193        } - 194    } - 195 - 196    private function handleImageDelete($imageName) { - 197        try { - 198            // Validar el nombre del archivo - 199            if (empty($imageName) || !is_string($imageName)) { - 200                return false; - 201            } - 202 - 203            // Verificar en la base de datos - 204            $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ? LIMIT 1"); - 205            $stmt->execute([$imageName]); - 206            $result = $stmt->fetch(\PDO::FETCH_ASSOC); - 207 - 208            if (!$result) { - 209                return false; - 210            } + 128            if($files['image']['size'] > 2000000) { + 129                return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; + 130            } + 131 + 132            $stmt = $this->conn->prepare("INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)"); + 133            if($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) { + 134                move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage()); + 135                return ['success' => true, 'message' => '¡Producto añadido exitosamente!']; + 136            } + 137        } catch (\Exception $e) { + 138            $this->handleDatabaseError($e); + 139            return ['success' => false, 'message' => 'Error al añadir el producto']; + 140        } + 141    } + 142 + 143    public function deleteProduct($id) { + 144        try { + 145            // Obtener información de la imagen + 146            $stmt = $this->conn->prepare("SELECT image FROM `products` WHERE id = ?"); + 147            $stmt->execute([$id]); + 148            $image_data = $stmt->fetch(\PDO::FETCH_ASSOC); + 149             + 150            if($image_data) { + 151                $imagePath = self::UPLOAD_PATH . $image_data['image']; + 152                if(file_exists($imagePath)) { + 153                    unlink($imagePath); + 154                } + 155            } + 156             + 157            $stmt = $this->conn->prepare("DELETE FROM `products` WHERE id = ?"); + 158            if($stmt->execute([$id])) { + 159                return ['success' => true, 'message' => 'Producto eliminado']; + 160            } + 161             + 162            return ['success' => false, 'message' => 'Error al eliminar el producto']; + 163        } catch (\Exception $e) { + 164            return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()]; + 165        } + 166    } + 167 + 168    private function validateImageName($imageName) { + 169        // Solo permitir letras, números, guiones y puntos + 170        return preg_match('/^[a-zA-Z0-9_.-]+$/', $imageName); + 171    } + 172 + 173    private function getSecureImagePath($imageName) { + 174        try { + 175            // Validar el nombre del archivo + 176            if (empty($imageName) || !is_string($imageName)) { + 177                throw new \Exception('Nombre de archivo inválido'); + 178            } + 179 + 180            // Obtener y validar la extensión + 181            $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION)); + 182            if (!in_array($extension, self::ALLOWED_EXTENSIONS)) { + 183                throw new \Exception('Tipo de archivo no permitido'); + 184            } + 185 + 186            // Verificar que el archivo existe en la base de datos + 187            $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ?"); + 188            $stmt->execute([$imageName]); + 189            if (!$stmt->fetch()) { + 190                throw new \Exception('Archivo no encontrado en la base de datos'); + 191            } + 192 + 193            return self::UPLOAD_PATH . $imageName; + 194        } catch (\Exception $e) { + 195            error_log("Error en getSecureImagePath: " . $e->getMessage()); + 196            return false; + 197        } + 198    } + 199 + 200    private function handleImageDelete($imageName) { + 201        try { + 202            // Validar el nombre del archivo + 203            if (empty($imageName) || !is_string($imageName)) { + 204                return false; + 205            } + 206 + 207            // Verificar en la base de datos + 208            $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ? LIMIT 1"); + 209            $stmt->execute([$imageName]); + 210            $result = $stmt->fetch(\PDO::FETCH_ASSOC); 211 - 212            // Construir y validar la ruta - 213            $fullPath = realpath(self::UPLOAD_PATH . $result['image']); - 214            $uploadDir = realpath(self::UPLOAD_PATH); + 212            if (!$result) { + 213                return false; + 214            } 215 - 216            // Verificar que el archivo está dentro del directorio permitido - 217            if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) { - 218                return false; - 219            } - 220 - 221            // Eliminar el archivo si existe - 222            if (file_exists($fullPath)) { - 223                return unlink($fullPath); - 224            } - 225 - 226            return false; - 227        } catch (\Exception $e) { - 228            error_log("Error al eliminar imagen: " . $e->getMessage()); - 229            return false; - 230        } - 231    } - 232 - 233    public function updateProduct($postData, $files) { - 234        try { - 235            $product = new Product(); - 236            $product->setId($postData['update_p_id']); - 237            $product->setName($postData['update_name']); - 238            $product->setPrice($postData['update_price']); - 239             - 240            if(!empty($files['update_image']['name'])) { - 241                if($files['update_image']['size'] > 2000000) { - 242                    return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; - 243                } - 244 - 245                // Eliminar imagen anterior de forma segura - 246                if (!empty($postData['update_old_image'])) { - 247                    $this->handleImageDelete($postData['update_old_image']); - 248                } - 249 - 250                // Generar nombre único para la nueva imagen - 251                $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); - 252                $newImageName = uniqid() . '.' . $extension; - 253                $product->setImage($newImageName); - 254                 - 255                // Subir nueva imagen - 256                move_uploaded_file( - 257                    $files['update_image']['tmp_name'],  - 258                    self::UPLOAD_PATH . $newImageName - 259                ); - 260                 - 261                $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); - 262                $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; - 263            } else { - 264                $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ? WHERE id = ?"); - 265                $params = [$product->getName(), $product->getPrice(), $product->getId()]; - 266            } - 267             - 268            if($stmt->execute($params)) { - 269                return ['success' => true, 'message' => 'Producto actualizado exitosamente']; + 216            // Construir y validar la ruta + 217            $fullPath = realpath(self::UPLOAD_PATH . $result['image']); + 218            $uploadDir = realpath(self::UPLOAD_PATH); + 219 + 220            // Verificar que el archivo está dentro del directorio permitido + 221            if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) { + 222                return false; + 223            } + 224 + 225            // Eliminar el archivo si existe + 226            if (file_exists($fullPath)) { + 227                return unlink($fullPath); + 228            } + 229 + 230            return false; + 231        } catch (\Exception $e) { + 232            error_log("Error al eliminar imagen: " . $e->getMessage()); + 233            return false; + 234        } + 235    } + 236 + 237    public function updateProduct($postData, $files) { + 238        try { + 239            $product = new Product(); + 240            $product->setId($postData['update_p_id']); + 241            $product->setName($postData['update_name']); + 242            $product->setPrice($postData['update_price']); + 243             + 244            if(!empty($files['update_image']['name'])) { + 245                if($files['update_image']['size'] > 2000000) { + 246                    return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; + 247                } + 248 + 249                // Eliminar imagen anterior de forma segura + 250                if (!empty($postData['update_old_image'])) { + 251                    $this->handleImageDelete($postData['update_old_image']); + 252                } + 253 + 254                // Generar nombre único para la nueva imagen + 255                $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); + 256                $newImageName = uniqid() . '.' . $extension; + 257                $product->setImage($newImageName); + 258                 + 259                // Subir nueva imagen + 260                move_uploaded_file( + 261                    $files['update_image']['tmp_name'],  + 262                    self::UPLOAD_PATH . $newImageName + 263                ); + 264                 + 265                $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); + 266                $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; + 267            } else { + 268                $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ? WHERE id = ?"); + 269                $params = [$product->getName(), $product->getPrice(), $product->getId()]; 270            } 271             - 272            return ['success' => false, 'message' => 'Error al actualizar el producto']; - 273        } catch (\Exception $e) { - 274            error_log("Error en updateProduct: " . $e->getMessage()); - 275            return ['success' => false, 'message' => 'Error al actualizar el producto']; - 276        } - 277    } - 278 - 279    public function getAllProducts() { - 280        $stmt = $this->conn->query("SELECT * FROM `products`"); - 281        $products = []; - 282        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 283            $product = new Product(); - 284            $product->setId($row['id']); - 285            $product->setName($row['name']); - 286            $product->setPrice($row['price']); - 287            $product->setImage($row['image']); - 288            $products[] = $product; - 289        } - 290        return $products; - 291    } - 292 - 293    public function getAllOrders() { - 294        $stmt = $this->conn->prepare("SELECT * FROM `orders`"); - 295        $stmt->execute(); - 296        $orders = []; - 297        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 298            $order = new Order(); - 299            $order->setId($row['id']); - 300            $order->setUserId($row['user_id']); - 301            $order->setPlacedOn($row['placed_on']); - 302            $order->setName($row['name']); - 303            $order->setNumber($row['number']); - 304            $order->setEmail($row['email']); - 305            $order->setAddress($row['address']); - 306            $order->setTotalProducts($row['total_products']); - 307            $order->setTotalPrice($row['total_price']); - 308            $order->setMethod($row['method']); - 309            $order->setPaymentStatus($row['payment_status']); - 310            $orders[] = $order; - 311        } - 312        return $orders; - 313    } - 314 - 315    public function updateOrderStatus($orderId, $status) { - 316        try { - 317            $order = new Order(); - 318            $order->setId($orderId); - 319            $order->setPaymentStatus($status); - 320             - 321            $stmt = $this->conn->prepare("UPDATE `orders` SET payment_status = ? WHERE id = ?"); - 322            return $stmt->execute([$order->getPaymentStatus(), $order->getId()]); - 323        } catch (\PDOException $e) { - 324            $this->handleDatabaseError($e); - 325            return false; - 326        } - 327    } - 328 - 329    public function deleteOrder($orderId) { - 330        try { - 331            $order = new Order(); - 332            $order->setId($orderId); - 333             - 334            $stmt = $this->conn->prepare("DELETE FROM `orders` WHERE id = ?"); - 335            return $stmt->execute([$order->getId()]); - 336        } catch (\PDOException $e) { - 337            $this->handleDatabaseError($e); - 338            return false; - 339        } - 340    } - 341 - 342    public function getAllUsers() { - 343        try { - 344            $stmt = $this->conn->prepare("SELECT * FROM `users`"); - 345            $stmt->execute(); - 346            $users = []; - 347             - 348            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 349                $user = new User(); - 350                $user->setId($row['id']); - 351                $user->setName($row['name']); - 352                $user->setEmail($row['email']); - 353                $user->setUserType($row['user_type']); - 354                $users[] = $user; - 355            } - 356            return $users; - 357        } catch (\PDOException $e) { - 358            $this->handleDatabaseError($e); - 359            return []; - 360        } - 361    } - 362 - 363    public function deleteUser($userId) { - 364        try { - 365            $user = new User(); - 366            $user->setId($userId); - 367             - 368            $stmt = $this->conn->prepare("DELETE FROM `users` WHERE id = ?"); - 369            return $stmt->execute([$user->getId()]); - 370        } catch (\PDOException $e) { - 371            $this->handleDatabaseError($e); - 372            return false; - 373        } - 374    } - 375 - 376    public function getAllMessages() { - 377        try { - 378            $stmt = $this->conn->query("SELECT * FROM `message`"); - 379            $messages = []; - 380            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 381                $message = new Message(); - 382                $message->setId($row['id']); - 383                $message->setUserId($row['user_id']); - 384                $message->setMessage($row['message']); - 385                $message->setName($row['name']); - 386                $message->setEmail($row['email']); - 387                $message->setNumber($row['number']); - 388                $messages[] = $message; - 389            } - 390            return $messages; - 391        } catch (\PDOException $e) { - 392            $this->handleDatabaseError($e); - 393            return []; - 394        } - 395    } - 396 - 397    public function deleteMessage($messageId) { - 398        try { - 399            $query = "DELETE FROM `message` WHERE id = ?"; - 400            $stmt = $this->conn->prepare($query); - 401            return $stmt->execute([$messageId]); - 402        } catch (\PDOException $e) { - 403            $this->handleDatabaseError($e); - 404            return false; - 405        } - 406    } - 407}  + 272            if($stmt->execute($params)) { + 273                return ['success' => true, 'message' => 'Producto actualizado exitosamente']; + 274            } + 275             + 276            return ['success' => false, 'message' => 'Error al actualizar el producto']; + 277        } catch (\Exception $e) { + 278            error_log("Error en updateProduct: " . $e->getMessage()); + 279            return ['success' => false, 'message' => 'Error al actualizar el producto']; + 280        } + 281    } + 282 + 283    public function getAllProducts() { + 284        $stmt = $this->conn->query("SELECT * FROM `products`"); + 285        $products = []; + 286        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 287            $product = new Product(); + 288            $product->setId($row['id']); + 289            $product->setName($row['name']); + 290            $product->setPrice($row['price']); + 291            $product->setImage($row['image']); + 292            $products[] = $product; + 293        } + 294        return $products; + 295    } + 296 + 297    public function getAllOrders() { + 298        $stmt = $this->conn->prepare("SELECT * FROM `orders`"); + 299        $stmt->execute(); + 300        $orders = []; + 301        foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 302            $order = new Order(); + 303            $order->setId($row['id']); + 304            $order->setUserId($row['user_id']); + 305            $order->setPlacedOn($row['placed_on']); + 306            $order->setName($row['name']); + 307            $order->setNumber($row['number']); + 308            $order->setEmail($row['email']); + 309            $order->setAddress($row['address']); + 310            $order->setTotalProducts($row['total_products']); + 311            $order->setTotalPrice($row['total_price']); + 312            $order->setMethod($row['method']); + 313            $order->setPaymentStatus($row['payment_status']); + 314            $orders[] = $order; + 315        } + 316        return $orders; + 317    } + 318 + 319    public function updateOrderStatus($orderId, $status) { + 320        try { + 321            $order = new Order(); + 322            $order->setId($orderId); + 323            $order->setPaymentStatus($status); + 324             + 325            $stmt = $this->conn->prepare("UPDATE `orders` SET payment_status = ? WHERE id = ?"); + 326            return $stmt->execute([$order->getPaymentStatus(), $order->getId()]); + 327        } catch (\PDOException $e) { + 328            $this->handleDatabaseError($e); + 329            return false; + 330        } + 331    } + 332 + 333    public function deleteOrder($orderId) { + 334        try { + 335            $order = new Order(); + 336            $order->setId($orderId); + 337             + 338            $stmt = $this->conn->prepare("DELETE FROM `orders` WHERE id = ?"); + 339            return $stmt->execute([$order->getId()]); + 340        } catch (\PDOException $e) { + 341            $this->handleDatabaseError($e); + 342            return false; + 343        } + 344    } + 345 + 346    public function getAllUsers() { + 347        try { + 348            $stmt = $this->conn->prepare("SELECT * FROM `users`"); + 349            $stmt->execute(); + 350            $users = []; + 351             + 352            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 353                $user = new User(); + 354                $user->setId($row['id']); + 355                $user->setName($row['name']); + 356                $user->setEmail($row['email']); + 357                $user->setUserType($row['user_type']); + 358                $users[] = $user; + 359            } + 360            return $users; + 361        } catch (\PDOException $e) { + 362            $this->handleDatabaseError($e); + 363            return []; + 364        } + 365    } + 366 + 367    public function deleteUser($userId) { + 368        try { + 369            $user = new User(); + 370            $user->setId($userId); + 371             + 372            $stmt = $this->conn->prepare("DELETE FROM `users` WHERE id = ?"); + 373            return $stmt->execute([$user->getId()]); + 374        } catch (\PDOException $e) { + 375            $this->handleDatabaseError($e); + 376            return false; + 377        } + 378    } + 379 + 380    public function getAllMessages() { + 381        try { + 382            $stmt = $this->conn->query("SELECT * FROM `message`"); + 383            $messages = []; + 384            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 385                $message = new Message(); + 386                $message->setId($row['id']); + 387                $message->setUserId($row['user_id']); + 388                $message->setMessage($row['message']); + 389                $message->setName($row['name']); + 390                $message->setEmail($row['email']); + 391                $message->setNumber($row['number']); + 392                $messages[] = $message; + 393            } + 394            return $messages; + 395        } catch (\PDOException $e) { + 396            $this->handleDatabaseError($e); + 397            return []; + 398        } + 399    } + 400 + 401    public function deleteMessage($messageId) { + 402        try { + 403            $query = "DELETE FROM `message` WHERE id = ?"; + 404            $stmt = $this->conn->prepare($query); + 405            return $stmt->execute([$messageId]); + 406        } catch (\PDOException $e) { + 407            $this->handleDatabaseError($e); + 408            return false; + 409        } + 410    } + 411}  @@ -1073,7 +1077,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/ContactController.php.html b/coverage/html/Controllers/ContactController.php.html index bafe49c3..7858b64b 100644 --- a/coverage/html/Controllers/ContactController.php.html +++ b/coverage/html/Controllers/ContactController.php.html @@ -197,8 +197,8 @@ 1<?php 2namespace Controllers; 3 - 4require_once __DIR__ . '/../Models/Message.php'; - 5require_once __DIR__ . '/../Models/User.php'; + 4require_once __DIR__ . '/../Models/Message.php'; + 5require_once __DIR__ . '/../Models/User.php'; 6use Models\Message; 7use Models\User; 8 @@ -206,7 +206,7 @@ 10    private $conn; 11 12    public function __construct($conn) { - 13        $this->conn = $conn; + 13        $this->conn = $conn; 14    } 15 16    // Agregar estos métodos protegidos para permitir el mock en las pruebas @@ -223,39 +223,39 @@ 27    public function sendMessage($userData) { 28        try { 29            // Validar que todos los campos requeridos existan - 30            if (!isset($userData['user_id']) || !isset($userData['name']) ||  - 31                !isset($userData['email']) || !isset($userData['message'])) { + 30            if (!isset($userData['user_id']) || !isset($userData['name']) ||  + 31                !isset($userData['email']) || !isset($userData['message'])) { 32                return ['success' => false, 'message' => 'Faltan campos requeridos']; 33            } 34 35            // Modificar la creación de User y Message - 36            $user = $this->createUser(); - 37            $user->setId($userData['user_id']); - 38            if (!$user->exists($this->conn)) { + 36            $user = $this->createUser(); + 37            $user->setId($userData['user_id']); + 38            if (!$user->exists($this->conn)) { 39                return ['success' => false, 'message' => 'Usuario no encontrado']; 40            } 41 - 42            $message = $this->createMessage(); - 43            $message->setUserId($userData['user_id']); - 44            $message->setName($userData['name']); - 45            $message->setEmail($userData['email']); - 46            $message->setNumber($userData['number']); - 47            $message->setMessage($userData['message']); + 42            $message = $this->createMessage(); + 43            $message->setUserId($userData['user_id']); + 44            $message->setName($userData['name']); + 45            $message->setEmail($userData['email']); + 46            $message->setNumber($userData['number']); + 47            $message->setMessage($userData['message']); 48 - 49            if ($message->exists($this->conn)) {  // Asumiendo que existe un método exists() en Message + 49            if ($message->exists($this->conn)) {  // Asumiendo que existe un método exists() en Message 50                return ['success' => false, 'message' => '¡Mensaje ya enviado!']; 51            } 52 - 53            if ($message->save($this->conn)) { - 54                return ['success' => true, 'message' => '¡Mensaje enviado exitosamente!']; + 53            if ($message->save($this->conn)) { + 54                return ['success' => true, 'message' => '¡Mensaje enviado exitosamente!']; 55            } 56 57            // Añadir log específico si save() falla 58            error_log("Error en save(): Falló al guardar el mensaje para usuario ID: " . $userData['user_id']); 59            return ['success' => false, 'message' => 'Error al enviar mensaje']; - 60        } catch (\Exception $e) { - 61            error_log("Error al enviar mensaje: " . $e->getMessage()); - 62            return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()]; + 60        } catch (\Exception $e) { + 61            error_log("Error al enviar mensaje: " . $e->getMessage()); + 62            return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()]; 63        } 64    } 65} @@ -269,7 +269,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/OrderController.php.html b/coverage/html/Controllers/OrderController.php.html index 500351d6..92f015cf 100644 --- a/coverage/html/Controllers/OrderController.php.html +++ b/coverage/html/Controllers/OrderController.php.html @@ -45,13 +45,13 @@ Total
-
- 81.53% covered (warning) +
+ 82.10% covered (warning)
-
81.53%
-
128 / 157
+
82.10%
+
133 / 162
58.33% covered (warning) @@ -74,13 +74,13 @@ OrderController
-
- 81.17% covered (warning) +
+ 81.76% covered (warning)
-
81.17%
-
125 / 154
+
81.76%
+
130 / 159
58.33% covered (warning) @@ -89,7 +89,7 @@
58.33%
7 / 12
- 33.24 + 36.83
0.00% covered (danger) @@ -219,7 +219,7 @@
100.00%
-
54 / 54
+
59 / 59
100.00% covered (success) @@ -228,12 +228,12 @@
100.00%
1 / 1
- 5 + 8 -  getCartItems +  
getCartItems
100.00% covered (success) @@ -255,7 +255,7 @@ -  clearCart +  clearCart
100.00% covered (success) @@ -277,7 +277,7 @@ -  getUserOrders +  getUserOrders
85.00% covered (warning) @@ -299,7 +299,7 @@ -  getAllProducts +  getAllProducts
100.00% covered (success) @@ -321,7 +321,7 @@ -  getAllUsers +  getAllUsers
100.00% covered (success) @@ -343,7 +343,7 @@ -  handleDatabaseError +  handleDatabaseError
100.00% covered (success) @@ -373,9 +373,9 @@ 1<?php 2namespace Controllers; 3 - 4require_once __DIR__ . '/../Models/Order.php'; - 5require_once __DIR__ . '/../Models/Product.php'; - 6require_once __DIR__ . '/../Models/User.php'; + 4require_once __DIR__ . '/../Models/Order.php'; + 5require_once __DIR__ . '/../Models/Product.php'; + 6require_once __DIR__ . '/../Models/User.php'; 7use Models\Order; 8use Models\Product; 9use Models\User; @@ -384,7 +384,7 @@ 12    private $conn; 13 14    public function __construct($conn) { - 15        $this->conn = $conn; + 15        $this->conn = $conn; 16    } 17 18    public function getOrders($userId) { @@ -436,21 +436,21 @@ 64 65    public function getAllOrders() { 66        try { - 67            $stmt = $this->conn->prepare("SELECT * FROM `orders`"); - 68            $stmt->execute(); - 69            $orders = []; - 70            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 71                $order = new Order(); - 72                $order->setUserId($row['user_id']); - 73                $order->setName($row['name']); - 74                $order->setEmail($row['email']); - 75                $order->setMethod($row['method']); - 76                $order->setAddress($row['address']); - 77                $order->setTotalProducts($row['total_products']); - 78                $order->setTotalPrice($row['total_price']); - 79                $orders[] = $order; + 67            $stmt = $this->conn->prepare("SELECT * FROM `orders`"); + 68            $stmt->execute(); + 69            $orders = []; + 70            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 71                $order = new Order(); + 72                $order->setUserId($row['user_id']); + 73                $order->setName($row['name']); + 74                $order->setEmail($row['email']); + 75                $order->setMethod($row['method']); + 76                $order->setAddress($row['address']); + 77                $order->setTotalProducts($row['total_products']); + 78                $order->setTotalPrice($row['total_price']); + 79                $orders[] = $order; 80            } - 81            return $orders; + 81            return $orders; 82        } catch (\Exception $e) { 83            $this->handleDatabaseError($e); 84            return []; @@ -459,166 +459,176 @@ 87 88    public function createOrder($userData, $userId) { 89        try { - 90            $order = new Order(); - 91            $order->setUserId($userId); - 92            $order->setName($userData['name']); - 93            $order->setNumber($userData['number']); - 94            $order->setEmail($userData['email']); - 95            $order->setMethod($userData['method']); + 90            $order = new Order(); + 91            $order->setUserId($userId); + 92            $order->setName($userData['name']); + 93            $order->setNumber($userData['number']); + 94            $order->setEmail($userData['email']); + 95            $order->setMethod($userData['method']); 96             97            // Obtener productos del carrito - 98            $cartItems = $this->getCartItems($userId); - 99            if(empty($cartItems)) { - 100                return ['success' => false, 'message' => 'El carrito está vacío']; + 98            $cartItems = $this->getCartItems($userId); + 99            if(empty($cartItems)) { + 100                return ['success' => false, 'message' => 'El carrito está vacío']; 101            } 102 - 103            // Calcular total y preparar lista de productos - 104            $cartTotal = 0; - 105            $products = []; - 106            foreach($cartItems as $item) { - 107                $products[] = $item['name'] . ' (' . $item['quantity'] . ')'; - 108                $cartTotal += ($item['price'] * $item['quantity']); - 109            } - 110            $totalProducts = implode(', ', $products); - 111 - 112            // Formatear y establecer dirección - 113            $address = 'flat no. ' . $userData['flat'] . ', ' .  - 114                      $userData['street'] . ', ' .  - 115                      $userData['city'] . ', ' .  - 116                      $userData['country'] . ' - ' .  - 117                      $userData['pin_code']; - 118             - 119            // Establecer valores adicionales en el objeto Order - 120            $order->setAddress($address); - 121            $order->setTotalProducts($totalProducts); - 122            $order->setTotalPrice($cartTotal); - 123             - 124            // Verificar si la orden ya existe - 125            $stmt = $this->conn->prepare("SELECT * FROM orders WHERE  - 126                name = ? AND number = ? AND email = ? AND  - 127                method = ? AND address = ? AND  - 128                total_products = ? AND total_price = ?"); - 129             - 130            $stmt->execute([ - 131                $order->getName(), - 132                $order->getNumber(), - 133                $order->getEmail(), - 134                $order->getMethod(), - 135                $order->getAddress(), - 136                $order->getTotalProducts(), - 137                $order->getTotalPrice() - 138            ]); - 139 - 140            if($stmt->rowCount() > 0) { - 141                return ['success' => false, 'message' => '¡Pedido ya realizado!']; - 142            } - 143 - 144            // Insertar nueva orden - 145            $stmt = $this->conn->prepare("INSERT INTO orders  - 146                (user_id, name, number, email, method, address,  - 147                total_products, total_price, placed_on)  - 148                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + 103            // Validar productos antes de procesar + 104            foreach($cartItems as $item) { + 105                if(empty($item['name'])) { + 106                    return ['success' => false, 'message' => 'Error: nombre de producto inválido']; + 107                } + 108                if($item['price'] < 0) { + 109                    return ['success' => false, 'message' => 'Error: precio inválido']; + 110                } + 111            } + 112 + 113            // Calcular total y preparar lista de productos + 114            $cartTotal = 0; + 115            $products = []; + 116            foreach($cartItems as $item) { + 117                $products[] = $item['name'] . ' (' . $item['quantity'] . ')'; + 118                $cartTotal += ($item['price'] * $item['quantity']); + 119            } + 120            $totalProducts = implode(', ', $products); + 121 + 122            // Formatear y establecer dirección + 123            $address = 'flat no. ' . $userData['flat'] . ', ' .  + 124                      $userData['street'] . ', ' .  + 125                      $userData['city'] . ', ' .  + 126                      $userData['country'] . ' - ' .  + 127                      $userData['pin_code']; + 128             + 129            // Establecer valores adicionales en el objeto Order + 130            $order->setAddress($address); + 131            $order->setTotalProducts($totalProducts); + 132            $order->setTotalPrice($cartTotal); + 133             + 134            // Verificar si la orden ya existe + 135            $stmt = $this->conn->prepare("SELECT * FROM orders WHERE  + 136                name = ? AND number = ? AND email = ? AND  + 137                method = ? AND address = ? AND  + 138                total_products = ? AND total_price = ?"); + 139             + 140            $stmt->execute([ + 141                $order->getName(), + 142                $order->getNumber(), + 143                $order->getEmail(), + 144                $order->getMethod(), + 145                $order->getAddress(), + 146                $order->getTotalProducts(), + 147                $order->getTotalPrice() + 148            ]); 149 - 150            $stmt->execute([ - 151                $order->getUserId(), - 152                $order->getName(), - 153                $order->getNumber(), - 154                $order->getEmail(), - 155                $order->getMethod(), - 156                $order->getAddress(), - 157                $order->getTotalProducts(), - 158                $order->getTotalPrice(), - 159                date('d-M-Y') - 160            ]); - 161 - 162            // Limpiar carrito - 163            $this->clearCart($userId); - 164 - 165            return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; - 166        } catch (\Exception $e) { - 167            error_log("Error al crear orden: " . $e->getMessage()); - 168            return ['success' => false, 'message' => 'Error al procesar el pedido']; - 169        } - 170    } + 150            if($stmt->rowCount() > 0) { + 151                return ['success' => false, 'message' => '¡Pedido ya realizado!']; + 152            } + 153 + 154            // Insertar nueva orden + 155            $stmt = $this->conn->prepare("INSERT INTO orders  + 156                (user_id, name, number, email, method, address,  + 157                total_products, total_price, placed_on)  + 158                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + 159 + 160            $stmt->execute([ + 161                $order->getUserId(), + 162                $order->getName(), + 163                $order->getNumber(), + 164                $order->getEmail(), + 165                $order->getMethod(), + 166                $order->getAddress(), + 167                $order->getTotalProducts(), + 168                $order->getTotalPrice(), + 169                date('d-M-Y') + 170            ]); 171 - 172    private function getCartItems($userId) { - 173        $stmt = $this->conn->prepare("SELECT * FROM cart WHERE user_id = ?"); - 174        $stmt->execute([$userId]); - 175        return $stmt->fetchAll(\PDO::FETCH_ASSOC); - 176    } - 177 - 178    private function clearCart($userId) { - 179        $stmt = $this->conn->prepare("DELETE FROM cart WHERE user_id = ?"); - 180        $stmt->execute([$userId]); - 181    } - 182 - 183    public function getUserOrders($userId) { - 184        try { - 185            $stmt = $this->conn->prepare("SELECT * FROM orders WHERE user_id = ?"); - 186            $stmt->execute([$userId]); - 187            $orders = []; - 188            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 189                $order = new Order(); - 190                $order->setUserId($row['user_id']); - 191                $order->setName($row['name']); - 192                $order->setNumber($row['number']); - 193                $order->setEmail($row['email']); - 194                $order->setMethod($row['method']); - 195                $order->setAddress($row['address']); - 196                $order->setTotalProducts($row['total_products']); - 197                $order->setTotalPrice($row['total_price']); - 198                $order->setPaymentStatus($row['payment_status']); - 199                $order->setPlacedOn($row['placed_on']); - 200                $orders[] = $order; - 201            } - 202            return $orders; - 203        } catch (\Exception $e) { - 204            error_log("Error al obtener órdenes del usuario: " . $e->getMessage()); - 205            return []; - 206        } - 207    } - 208 - 209    public function getAllProducts() { - 210        try { - 211            $stmt = $this->conn->query("SELECT * FROM `products`"); - 212            $products = []; - 213            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 214                $product = new Product(); - 215                $product->setName($row['name']); - 216                $product->setPrice($row['price']); - 217                $product->setImage($row['image']); - 218                $products[] = $product; - 219            } - 220            return $products; - 221        } catch (\Exception $e) { - 222            $this->handleDatabaseError($e); - 223            return []; - 224        } - 225    } - 226 - 227    public function getAllUsers() { - 228        try { - 229            $stmt = $this->conn->prepare("SELECT * FROM `users`"); - 230            $stmt->execute(); - 231            $users = []; - 232            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - 233                $user = new User(); - 234                $user->setName($row['name']); - 235                $user->setEmail($row['email']); - 236                $user->setUserType($row['user_type']); - 237                $users[] = $user; - 238            } - 239            return $users; - 240        } catch (\Exception $e) { - 241            $this->handleDatabaseError($e); - 242            return []; - 243        } - 244    } - 245 - 246    private function handleDatabaseError(\Exception $e) { - 247        error_log("Error en la base de datos: " . $e->getMessage()); - 248    } - 249}  + 172            // Limpiar carrito + 173            $this->clearCart($userId); + 174 + 175            return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; + 176        } catch (\Exception $e) { + 177            error_log("Error al crear orden: " . $e->getMessage()); + 178            return ['success' => false, 'message' => 'Error al procesar el pedido']; + 179        } + 180    } + 181 + 182    private function getCartItems($userId) { + 183        $stmt = $this->conn->prepare("SELECT * FROM cart WHERE user_id = ?"); + 184        $stmt->execute([$userId]); + 185        return $stmt->fetchAll(\PDO::FETCH_ASSOC); + 186    } + 187 + 188    private function clearCart($userId) { + 189        $stmt = $this->conn->prepare("DELETE FROM cart WHERE user_id = ?"); + 190        $stmt->execute([$userId]); + 191    } + 192 + 193    public function getUserOrders($userId) { + 194        try { + 195            $stmt = $this->conn->prepare("SELECT * FROM orders WHERE user_id = ?"); + 196            $stmt->execute([$userId]); + 197            $orders = []; + 198            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 199                $order = new Order(); + 200                $order->setUserId($row['user_id']); + 201                $order->setName($row['name']); + 202                $order->setNumber($row['number']); + 203                $order->setEmail($row['email']); + 204                $order->setMethod($row['method']); + 205                $order->setAddress($row['address']); + 206                $order->setTotalProducts($row['total_products']); + 207                $order->setTotalPrice($row['total_price']); + 208                $order->setPaymentStatus($row['payment_status']); + 209                $order->setPlacedOn($row['placed_on']); + 210                $orders[] = $order; + 211            } + 212            return $orders; + 213        } catch (\Exception $e) { + 214            error_log("Error al obtener órdenes del usuario: " . $e->getMessage()); + 215            return []; + 216        } + 217    } + 218 + 219    public function getAllProducts() { + 220        try { + 221            $stmt = $this->conn->query("SELECT * FROM `products`"); + 222            $products = []; + 223            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 224                $product = new Product(); + 225                $product->setName($row['name']); + 226                $product->setPrice($row['price']); + 227                $product->setImage($row['image']); + 228                $products[] = $product; + 229            } + 230            return $products; + 231        } catch (\Exception $e) { + 232            $this->handleDatabaseError($e); + 233            return []; + 234        } + 235    } + 236 + 237    public function getAllUsers() { + 238        try { + 239            $stmt = $this->conn->prepare("SELECT * FROM `users`"); + 240            $stmt->execute(); + 241            $users = []; + 242            foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + 243                $user = new User(); + 244                $user->setName($row['name']); + 245                $user->setEmail($row['email']); + 246                $user->setUserType($row['user_type']); + 247                $users[] = $user; + 248            } + 249            return $users; + 250        } catch (\Exception $e) { + 251            $this->handleDatabaseError($e); + 252            return []; + 253        } + 254    } + 255 + 256    private function handleDatabaseError(\Exception $e) { + 257        error_log("Error en la base de datos: " . $e->getMessage()); + 258    } + 259}  @@ -629,7 +639,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/ProductController.php.html b/coverage/html/Controllers/ProductController.php.html index 6f456a7f..a7a8e02a 100644 --- a/coverage/html/Controllers/ProductController.php.html +++ b/coverage/html/Controllers/ProductController.php.html @@ -295,13 +295,13 @@ 11    private $conn; 12 13    public function __construct($conn) { - 14        $this->conn = $conn; + 14        $this->conn = $conn; 15    } 16 17    public function getLatestProducts($limit = 6) { 18        try { - 19            $query = "SELECT * FROM products LIMIT :limit"; - 20            $stmt = $this->conn->prepare($query); + 19            $query = "SELECT * FROM products LIMIT :limit"; + 20            $stmt = $this->conn->prepare($query); 21            $stmt->bindValue(':limit', $limit, \PDO::PARAM_INT); 22            $stmt->execute(); 23             @@ -323,18 +323,18 @@ 39 40    public function addToCart($userId, $productData) { 41        try { - 42            $cart = new Cart(); - 43            $cart->setUserId($userId); - 44            $cart->setName($productData['product_name']); - 45            $cart->setPrice($productData['product_price']); - 46            $cart->setQuantity($productData['product_quantity']); - 47            $cart->setImage($productData['product_image']); + 42            $cart = new Cart(); + 43            $cart->setUserId($userId); + 44            $cart->setName($productData['product_name']); + 45            $cart->setPrice($productData['product_price']); + 46            $cart->setQuantity($productData['product_quantity']); + 47            $cart->setImage($productData['product_image']); 48             49            // Verificar si el producto ya está en el carrito - 50            $stmt = $this->conn->prepare("SELECT * FROM cart WHERE user_id = ? AND name = ?"); - 51            $stmt->execute([$userId, $cart->getName()]); + 50            $stmt = $this->conn->prepare("SELECT * FROM cart WHERE user_id = ? AND name = ?"); + 51            $stmt->execute([$userId, $cart->getName()]); 52             - 53            if($stmt->rowCount() > 0) { + 53            if($stmt->rowCount() > 0) { 54                return ['success' => false, 'message' => 'El producto ya está en el carrito']; 55            } 56 @@ -382,10 +382,10 @@ 98 99    public function getCartItems($userId) { 100        try { - 101            $query = "SELECT * FROM cart WHERE user_id = ?"; - 102            $stmt = $this->conn->prepare($query); - 103            $stmt->execute([$userId]); - 104            return $stmt->fetchAll(\PDO::FETCH_ASSOC); + 101            $query = "SELECT * FROM cart WHERE user_id = ?"; + 102            $stmt = $this->conn->prepare($query); + 103            $stmt->execute([$userId]); + 104            return $stmt->fetchAll(\PDO::FETCH_ASSOC); 105        } catch (\Exception $e) { 106            error_log("Error al obtener items del carrito: " . $e->getMessage()); 107            return []; @@ -394,9 +394,9 @@ 110 111    public function updateCartQuantity($cartId, $quantity) { 112        try { - 113            $query = "UPDATE cart SET quantity = ? WHERE id = ?"; - 114            $stmt = $this->conn->prepare($query); - 115            $stmt->execute([$quantity, $cartId]); + 113            $query = "UPDATE cart SET quantity = ? WHERE id = ?"; + 114            $stmt = $this->conn->prepare($query); + 115            $stmt->execute([$quantity, $cartId]); 116            return ['success' => true, 'message' => '¡Cantidad actualizada!']; 117        } catch (\Exception $e) { 118            error_log("Error al actualizar cantidad: " . $e->getMessage()); @@ -438,7 +438,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/SearchController.php.html b/coverage/html/Controllers/SearchController.php.html index 02346065..e63b7034 100644 --- a/coverage/html/Controllers/SearchController.php.html +++ b/coverage/html/Controllers/SearchController.php.html @@ -157,19 +157,19 @@ 5    private $conn; 6 7    public function __construct($conn) { - 8        $this->conn = $conn; + 8        $this->conn = $conn; 9    } 10 11    public function searchProducts($searchTerm) { 12        try { - 13            $searchTerm = "%{$searchTerm}%"; - 14            $stmt = $this->conn->prepare("SELECT * FROM products WHERE name LIKE ?"); + 13            $searchTerm = "%{$searchTerm}%"; + 14            $stmt = $this->conn->prepare("SELECT * FROM products WHERE name LIKE ?"); 15            $stmt->execute([$searchTerm]); 16             17            return $stmt->fetchAll(\PDO::FETCH_ASSOC); - 18        } catch (\Exception $e) { - 19            error_log("Error en búsqueda: " . $e->getMessage()); - 20            return []; + 18        } catch (\Exception $e) { + 19            error_log("Error en búsqueda: " . $e->getMessage()); + 20            return []; 21        } 22    } 23}  @@ -183,7 +183,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/UserController.php.html b/coverage/html/Controllers/UserController.php.html index 74dddaca..d86ad3b0 100644 --- a/coverage/html/Controllers/UserController.php.html +++ b/coverage/html/Controllers/UserController.php.html @@ -292,45 +292,45 @@ 8    private const HASH_COST = 12; // Costo de hash para password_hash 9 10    public function __construct($conn) { - 11        $this->conn = $conn; + 11        $this->conn = $conn; 12    } 13 14    private function hashPassword($password) { - 15        return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]); + 15        return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]); 16    } 17 18    private function verifyPassword($password, $hashedPassword) { - 19        return password_verify($password, $hashedPassword); + 19        return password_verify($password, $hashedPassword); 20    } 21 22    public function registerUser($userData) { 23        try { - 24            $user = new User(); - 25            $user->setName($userData['name']); - 26            $user->setEmail($userData['email']); - 27            $user->setUserType($userData['user_type'] ?? 'user'); + 24            $user = new User(); + 25            $user->setName($userData['name']); + 26            $user->setEmail($userData['email']); + 27            $user->setUserType($userData['user_type'] ?? 'user'); 28 29            // Verificar si el correo ya existe - 30            $stmt = $this->conn->prepare("SELECT id FROM users WHERE email = ?"); - 31            $stmt->execute([$user->getEmail()]); - 32            if($stmt->fetch()) { + 30            $stmt = $this->conn->prepare("SELECT id FROM users WHERE email = ?"); + 31            $stmt->execute([$user->getEmail()]); + 32            if($stmt->fetch()) { 33                return ['success' => false, 'message' => 'El correo ya está registrado']; 34            } 35 36            // Usar password_hash en lugar de md5 - 37            $stmt = $this->conn->prepare( - 38                "INSERT INTO users (name, email, password, user_type)  - 39                 VALUES (?, ?, ?, ?)" - 40            ); + 37            $stmt = $this->conn->prepare( + 38                "INSERT INTO users (name, email, password, user_type)  + 39                 VALUES (?, ?, ?, ?)" + 40            ); 41             - 42            $stmt->execute([ - 43                $user->getName(), - 44                $user->getEmail(), - 45                $this->hashPassword($userData['password']), - 46                $user->getUserType() - 47            ]); + 42            $stmt->execute([ + 43                $user->getName(), + 44                $user->getEmail(), + 45                $this->hashPassword($userData['password']), + 46                $user->getUserType() + 47            ]); 48             - 49            return ['success' => true, 'message' => 'Registro exitoso!']; + 49            return ['success' => true, 'message' => 'Registro exitoso!']; 50        } catch (\Exception $e) { 51            error_log("Error en registro: " . $e->getMessage()); 52            return ['success' => false, 'message' => 'Error en el registro']; @@ -339,22 +339,22 @@ 55 56    public function loginUser($email, $password) { 57        try { - 58            $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?"); - 59            $stmt->execute([$email]); - 60            $user = $stmt->fetch(\PDO::FETCH_ASSOC); + 58            $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?"); + 59            $stmt->execute([$email]); + 60            $user = $stmt->fetch(\PDO::FETCH_ASSOC); 61 - 62            if ($user && $this->verifyPassword($password, $user['password'])) { - 63                $_SESSION['user_id'] = $user['id']; - 64                $_SESSION['user_name'] = $user['name']; - 65                $_SESSION['user_type'] = $user['user_type']; - 66                $_SESSION['user_email'] = $user['email']; - 67                return ['success' => true, 'user_type' => $user['user_type']]; + 62            if ($user && $this->verifyPassword($password, $user['password'])) { + 63                $_SESSION['user_id'] = $user['id']; + 64                $_SESSION['user_name'] = $user['name']; + 65                $_SESSION['user_type'] = $user['user_type']; + 66                $_SESSION['user_email'] = $user['email']; + 67                return ['success' => true, 'user_type' => $user['user_type']]; 68            } 69 - 70            return ['success' => false, 'message' => 'Correo o contraseña incorrectos']; - 71        } catch (\Exception $e) { - 72            error_log("Error en login: " . $e->getMessage()); - 73            return ['success' => false, 'message' => 'Error en el inicio de sesión']; + 70            return ['success' => false, 'message' => 'Correo o contraseña incorrectos']; + 71        } catch (\Exception $e) { + 72            error_log("Error en login: " . $e->getMessage()); + 73            return ['success' => false, 'message' => 'Error en el inicio de sesión']; 74        } 75    } 76 @@ -382,12 +382,12 @@ 98 99    public function getUserById($userId) { 100        try { - 101            $stmt = $this->conn->prepare("SELECT id, name, email, user_type FROM users WHERE id = ?"); - 102            $stmt->execute([$userId]); - 103            return $stmt->fetch(\PDO::FETCH_ASSOC); - 104        } catch (\Exception $e) { - 105            error_log("Error al obtener usuario: " . $e->getMessage()); - 106            return null; + 101            $stmt = $this->conn->prepare("SELECT id, name, email, user_type FROM users WHERE id = ?"); + 102            $stmt->execute([$userId]); + 103            return $stmt->fetch(\PDO::FETCH_ASSOC); + 104        } catch (\Exception $e) { + 105            error_log("Error al obtener usuario: " . $e->getMessage()); + 106            return null; 107        } 108    } 109 @@ -406,7 +406,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Controllers/dashboard.html b/coverage/html/Controllers/dashboard.html index 07f37bfa..0beefc43 100644 --- a/coverage/html/Controllers/dashboard.html +++ b/coverage/html/Controllers/dashboard.html @@ -59,8 +59,8 @@

Insufficient Coverage

Controllers\OrderController81% - Controllers\AdminController83% Controllers\UserController83% + Controllers\AdminController84% @@ -77,8 +77,8 @@

Project Risks

- Controllers\AdminController80 - Controllers\OrderController33 + Controllers\AdminController78 + Controllers\OrderController36 Controllers\UserController17 @@ -117,24 +117,23 @@

Insufficient Coverage

- validateImageName0% + validateImageName0% logout0% getOrders19% updatePaymentStatus40% deleteOrder40% - deleteMessage50% - deleteOrder57% - deleteUser57% - updateOrderStatus62% - handleImageDelete64% - deleteProduct69% - addProduct76% - getAllUsers78% - getAllMessages80% + deleteMessage50% + deleteOrder57% + deleteUser57% + updateOrderStatus62% + handleImageDelete64% + addProduct76% + deleteProduct76% + getAllUsers78% + getAllMessages80% getAllOrders82% - getSecureImagePath84% - getUserOrders85% - updateProduct88% + getUserOrders85% + updateProduct88% @@ -152,22 +151,21 @@

Project Risks

logout12 - handleImageDelete10 + handleImageDelete10 getOrders7 - getSecureImagePath6 - updateProduct6 - deleteProduct5 - addProduct5 - getAllUsers3 - getAllMessages3 + updateProduct6 + addProduct5 + deleteProduct5 + getAllUsers3 + getAllMessages3 getAllOrders3 - getUserOrders3 + getUserOrders3 updatePaymentStatus2 deleteOrder2 - deleteMessage2 - deleteOrder2 - deleteUser2 - updateOrderStatus2 + deleteMessage2 + deleteOrder2 + deleteUser2 + updateOrderStatus2 @@ -177,7 +175,7 @@

Project Risks

@@ -214,7 +212,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([2,0,1,0,0,2,3,3,2,5,0,41], "Method Coverage")) + .datum(getCoverageDistributionData([2,0,1,0,0,2,3,2,3,4,1,41], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -264,7 +262,7 @@

Project Risks

chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[83.25991189427313,62,"Controllers\\AdminController<\/a>"],[100,12,"Controllers\\ContactController<\/a>"],[81.16883116883116,28,"Controllers\\OrderController<\/a>"],[100,18,"Controllers\\ProductController<\/a>"],[100,3,"Controllers\\SearchController<\/a>"],[83.33333333333334,16,"Controllers\\UserController<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[84.27947598253274,63,"Controllers\\AdminController<\/a>"],[100,12,"Controllers\\ContactController<\/a>"],[81.76100628930818,31,"Controllers\\OrderController<\/a>"],[100,18,"Controllers\\ProductController<\/a>"],[100,3,"Controllers\\SearchController<\/a>"],[83.33333333333334,16,"Controllers\\UserController<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -288,7 +286,7 @@

Project Risks

chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,1,"
Controllers\\AdminController::__construct<\/a>"],[100,1,"Controllers\\AdminController::getDashboardData<\/a>"],[100,2,"Controllers\\AdminController::getTotalPendings<\/a>"],[100,2,"Controllers\\AdminController::getTotalCompleted<\/a>"],[100,1,"Controllers\\AdminController::getOrdersCount<\/a>"],[100,1,"Controllers\\AdminController::getProductsCount<\/a>"],[100,1,"Controllers\\AdminController::getUsersCount<\/a>"],[100,1,"Controllers\\AdminController::getAdminsCount<\/a>"],[100,1,"Controllers\\AdminController::getTotalAccounts<\/a>"],[100,1,"Controllers\\AdminController::getMessagesCount<\/a>"],[100,1,"Controllers\\AdminController::handleDatabaseError<\/a>"],[76.47058823529412,5,"Controllers\\AdminController::addProduct<\/a>"],[69.23076923076923,5,"Controllers\\AdminController::deleteProduct<\/a>"],[0,1,"Controllers\\AdminController::validateImageName<\/a>"],[84.61538461538461,6,"Controllers\\AdminController::getSecureImagePath<\/a>"],[64.70588235294117,8,"Controllers\\AdminController::handleImageDelete<\/a>"],[88.46153846153845,6,"Controllers\\AdminController::updateProduct<\/a>"],[100,2,"Controllers\\AdminController::getAllProducts<\/a>"],[100,2,"Controllers\\AdminController::getAllOrders<\/a>"],[62.5,2,"Controllers\\AdminController::updateOrderStatus<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteOrder<\/a>"],[78.57142857142857,3,"Controllers\\AdminController::getAllUsers<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteUser<\/a>"],[80,3,"Controllers\\AdminController::getAllMessages<\/a>"],[50,2,"Controllers\\AdminController::deleteMessage<\/a>"],[100,1,"Controllers\\ContactController::__construct<\/a>"],[100,1,"Controllers\\ContactController::createUser<\/a>"],[100,1,"Controllers\\ContactController::createMessage<\/a>"],[100,9,"Controllers\\ContactController::sendMessage<\/a>"],[100,1,"Controllers\\OrderController::__construct<\/a>"],[19.047619047619047,3,"Controllers\\OrderController::getOrders<\/a>"],[40,2,"Controllers\\OrderController::updatePaymentStatus<\/a>"],[40,2,"Controllers\\OrderController::deleteOrder<\/a>"],[82.35294117647058,3,"Controllers\\OrderController::getAllOrders<\/a>"],[100,5,"Controllers\\OrderController::createOrder<\/a>"],[100,1,"Controllers\\OrderController::getCartItems<\/a>"],[100,1,"Controllers\\OrderController::clearCart<\/a>"],[85,3,"Controllers\\OrderController::getUserOrders<\/a>"],[100,3,"Controllers\\OrderController::getAllProducts<\/a>"],[100,3,"Controllers\\OrderController::getAllUsers<\/a>"],[100,1,"Controllers\\OrderController::handleDatabaseError<\/a>"],[100,1,"Controllers\\ProductController::__construct<\/a>"],[100,3,"Controllers\\ProductController::getLatestProducts<\/a>"],[100,3,"Controllers\\ProductController::addToCart<\/a>"],[100,3,"Controllers\\ProductController::getAllProducts<\/a>"],[100,2,"Controllers\\ProductController::getCartItems<\/a>"],[100,2,"Controllers\\ProductController::updateCartQuantity<\/a>"],[100,2,"Controllers\\ProductController::deleteCartItem<\/a>"],[100,2,"Controllers\\ProductController::deleteAllCartItems<\/a>"],[100,1,"Controllers\\SearchController::__construct<\/a>"],[100,2,"Controllers\\SearchController::searchProducts<\/a>"],[100,1,"Controllers\\UserController::__construct<\/a>"],[100,1,"Controllers\\UserController::hashPassword<\/a>"],[100,1,"Controllers\\UserController::verifyPassword<\/a>"],[100,3,"Controllers\\UserController::registerUser<\/a>"],[100,4,"Controllers\\UserController::loginUser<\/a>"],[0,3,"Controllers\\UserController::logout<\/a>"],[100,2,"Controllers\\UserController::getUserById<\/a>"],[100,1,"Controllers\\UserController::register<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,1,"Controllers\\AdminController::__construct<\/a>"],[100,1,"Controllers\\AdminController::getDashboardData<\/a>"],[100,3,"Controllers\\AdminController::getTotalPendings<\/a>"],[100,2,"Controllers\\AdminController::getTotalCompleted<\/a>"],[100,1,"Controllers\\AdminController::getOrdersCount<\/a>"],[100,1,"Controllers\\AdminController::getProductsCount<\/a>"],[100,1,"Controllers\\AdminController::getUsersCount<\/a>"],[100,1,"Controllers\\AdminController::getAdminsCount<\/a>"],[100,1,"Controllers\\AdminController::getTotalAccounts<\/a>"],[100,1,"Controllers\\AdminController::getMessagesCount<\/a>"],[100,1,"Controllers\\AdminController::handleDatabaseError<\/a>"],[76.47058823529412,5,"Controllers\\AdminController::addProduct<\/a>"],[76.92307692307693,5,"Controllers\\AdminController::deleteProduct<\/a>"],[0,1,"Controllers\\AdminController::validateImageName<\/a>"],[92.3076923076923,6,"Controllers\\AdminController::getSecureImagePath<\/a>"],[64.70588235294117,8,"Controllers\\AdminController::handleImageDelete<\/a>"],[88.46153846153845,6,"Controllers\\AdminController::updateProduct<\/a>"],[100,2,"Controllers\\AdminController::getAllProducts<\/a>"],[100,2,"Controllers\\AdminController::getAllOrders<\/a>"],[62.5,2,"Controllers\\AdminController::updateOrderStatus<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteOrder<\/a>"],[78.57142857142857,3,"Controllers\\AdminController::getAllUsers<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteUser<\/a>"],[80,3,"Controllers\\AdminController::getAllMessages<\/a>"],[50,2,"Controllers\\AdminController::deleteMessage<\/a>"],[100,1,"Controllers\\ContactController::__construct<\/a>"],[100,1,"Controllers\\ContactController::createUser<\/a>"],[100,1,"Controllers\\ContactController::createMessage<\/a>"],[100,9,"Controllers\\ContactController::sendMessage<\/a>"],[100,1,"Controllers\\OrderController::__construct<\/a>"],[19.047619047619047,3,"Controllers\\OrderController::getOrders<\/a>"],[40,2,"Controllers\\OrderController::updatePaymentStatus<\/a>"],[40,2,"Controllers\\OrderController::deleteOrder<\/a>"],[82.35294117647058,3,"Controllers\\OrderController::getAllOrders<\/a>"],[100,8,"Controllers\\OrderController::createOrder<\/a>"],[100,1,"Controllers\\OrderController::getCartItems<\/a>"],[100,1,"Controllers\\OrderController::clearCart<\/a>"],[85,3,"Controllers\\OrderController::getUserOrders<\/a>"],[100,3,"Controllers\\OrderController::getAllProducts<\/a>"],[100,3,"Controllers\\OrderController::getAllUsers<\/a>"],[100,1,"Controllers\\OrderController::handleDatabaseError<\/a>"],[100,1,"Controllers\\ProductController::__construct<\/a>"],[100,3,"Controllers\\ProductController::getLatestProducts<\/a>"],[100,3,"Controllers\\ProductController::addToCart<\/a>"],[100,3,"Controllers\\ProductController::getAllProducts<\/a>"],[100,2,"Controllers\\ProductController::getCartItems<\/a>"],[100,2,"Controllers\\ProductController::updateCartQuantity<\/a>"],[100,2,"Controllers\\ProductController::deleteCartItem<\/a>"],[100,2,"Controllers\\ProductController::deleteAllCartItems<\/a>"],[100,1,"Controllers\\SearchController::__construct<\/a>"],[100,2,"Controllers\\SearchController::searchProducts<\/a>"],[100,1,"Controllers\\UserController::__construct<\/a>"],[100,1,"Controllers\\UserController::hashPassword<\/a>"],[100,1,"Controllers\\UserController::verifyPassword<\/a>"],[100,3,"Controllers\\UserController::registerUser<\/a>"],[100,4,"Controllers\\UserController::loginUser<\/a>"],[0,3,"Controllers\\UserController::logout<\/a>"],[100,2,"Controllers\\UserController::getUserById<\/a>"],[100,1,"Controllers\\UserController::register<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/html/Controllers/index.html b/coverage/html/Controllers/index.html index 0d284c80..2f0d3cf5 100644 --- a/coverage/html/Controllers/index.html +++ b/coverage/html/Controllers/index.html @@ -45,13 +45,13 @@ Total
-
- 86.43% covered (warning) +
+ 86.95% covered (warning)
-
86.43%
-
484 / 560
+
86.95%
+
493 / 567
69.49% covered (warning) @@ -73,13 +73,13 @@ AdminController.php
-
- 83.33% covered (warning) +
+ 84.35% covered (warning)
-
83.33%
-
190 / 228
+
84.35%
+
194 / 230
52.00% covered (warning) @@ -129,13 +129,13 @@ OrderController.php
-
- 81.53% covered (warning) +
+ 82.10% covered (warning)
-
81.53%
-
128 / 157
+
82.10%
+
133 / 162
58.33% covered (warning) @@ -251,7 +251,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Exceptions/DatabaseException.php.html b/coverage/html/Exceptions/DatabaseException.php.html index 35fcaf8c..5b64810b 100644 --- a/coverage/html/Exceptions/DatabaseException.php.html +++ b/coverage/html/Exceptions/DatabaseException.php.html @@ -133,7 +133,7 @@ 3 4class DatabaseException extends \Exception { 5    public function __construct(string $message = "", int $code = 0, \Throwable $previous = null) { - 6        parent::__construct($message, $code, $previous); + 6        parent::__construct($message, $code, $previous); 7    } 8}  @@ -146,7 +146,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Exceptions/dashboard.html b/coverage/html/Exceptions/dashboard.html index cae3332d..5aff3c2b 100644 --- a/coverage/html/Exceptions/dashboard.html +++ b/coverage/html/Exceptions/dashboard.html @@ -136,7 +136,7 @@

Project Risks

diff --git a/coverage/html/Exceptions/index.html b/coverage/html/Exceptions/index.html index a0c2dbfa..7e068135 100644 --- a/coverage/html/Exceptions/index.html +++ b/coverage/html/Exceptions/index.html @@ -111,7 +111,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Models/Cart.php.html b/coverage/html/Models/Cart.php.html index bea916c9..231630dc 100644 --- a/coverage/html/Models/Cart.php.html +++ b/coverage/html/Models/Cart.php.html @@ -362,17 +362,17 @@ 12    // Getters 13    public function getId() { return $this->id; } 14    public function getUserId() { return $this->userId; } - 15    public function getName() { return $this->name; } + 15    public function getName() { return $this->name; } 16    public function getPrice() { return $this->price; } 17    public function getQuantity() { return $this->quantity; } 18    public function getImage() { return $this->image; } 19 20    // Setters - 21    public function setUserId($userId) { $this->userId = $userId; } - 22    public function setName($name) { $this->name = $name; } - 23    public function setPrice($price) { $this->price = $price; } - 24    public function setQuantity($quantity) { $this->quantity = $quantity; } - 25    public function setImage($image) { $this->image = $image; } + 21    public function setUserId($userId) { $this->userId = $userId; } + 22    public function setName($name) { $this->name = $name; } + 23    public function setPrice($price) { $this->price = $price; } + 24    public function setQuantity($quantity) { $this->quantity = $quantity; } + 25    public function setImage($image) { $this->image = $image; } 26}  @@ -384,7 +384,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Models/Message.php.html b/coverage/html/Models/Message.php.html index 7f5fbf56..5b2d6fe4 100644 --- a/coverage/html/Models/Message.php.html +++ b/coverage/html/Models/Message.php.html @@ -429,16 +429,16 @@ 13    public function getId() { return $this->id; } 14    public function getUserId() { return $this->userId; } 15    public function getName() { return $this->name; } - 16    public function getEmail() { return $this->email; } + 16    public function getEmail() { return $this->email; } 17    public function getNumber() { return $this->number; } - 18    public function getMessage() { return $this->message; } + 18    public function getMessage() { return $this->message; } 19 20    // Setters - 21    public function setUserId($userId) { $this->userId = $userId; } - 22    public function setName($name) { $this->name = $name; } - 23    public function setEmail($email) { $this->email = $email; } - 24    public function setNumber($number) { $this->number = $number; } - 25    public function setMessage($message) { $this->message = $message; } + 21    public function setUserId($userId) { $this->userId = $userId; } + 22    public function setName($name) { $this->name = $name; } + 23    public function setEmail($email) { $this->email = $email; } + 24    public function setNumber($number) { $this->number = $number; } + 25    public function setMessage($message) { $this->message = $message; } 26 27    public function exists($conn) { 28        $sql = "SELECT id FROM message WHERE user_id = ? AND message = ?"; @@ -459,7 +459,7 @@ 43        ]); 44    } 45 - 46    public function setId($id) { $this->id = $id; } + 46    public function setId($id) { $this->id = $id; } 47}  @@ -471,7 +471,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Models/Order.php.html b/coverage/html/Models/Order.php.html index 3c4f1645..5ec77181 100644 --- a/coverage/html/Models/Order.php.html +++ b/coverage/html/Models/Order.php.html @@ -608,32 +608,32 @@ 16 17    // Getters 18    public function getId() { return $this->id; } - 19    public function getUserId() { return $this->userId; } - 20    public function getName() { return $this->name; } - 21    public function getNumber() { return $this->number; } - 22    public function getEmail() { return $this->email; } - 23    public function getMethod() { return $this->method; } - 24    public function getAddress() { return $this->address; } - 25    public function getTotalProducts() { return $this->totalProducts; } - 26    public function getTotalPrice() { return $this->totalPrice; } + 19    public function getUserId() { return $this->userId; } + 20    public function getName() { return $this->name; } + 21    public function getNumber() { return $this->number; } + 22    public function getEmail() { return $this->email; } + 23    public function getMethod() { return $this->method; } + 24    public function getAddress() { return $this->address; } + 25    public function getTotalProducts() { return $this->totalProducts; } + 26    public function getTotalPrice() { return $this->totalPrice; } 27    public function getPlacedOn() { return $this->placedOn; } 28    public function getPaymentStatus() { return $this->paymentStatus; } 29 30    // Setters - 31    public function setUserId($userId) { $this->userId = $userId; } - 32    public function setName($name) { $this->name = $name; } - 33    public function setNumber($number) { $this->number = $number; } - 34    public function setEmail($email) { $this->email = $email; } - 35    public function setMethod($method) { $this->method = $method; } - 36    public function setAddress($address) { $this->address = $address; } - 37    public function setTotalProducts($totalProducts) { $this->totalProducts = $totalProducts; } - 38    public function setTotalPrice($totalPrice) { $this->totalPrice = $totalPrice; } - 39    public function setPaymentStatus($status) { $this->paymentStatus = $status; } + 31    public function setUserId($userId) { $this->userId = $userId; } + 32    public function setName($name) { $this->name = $name; } + 33    public function setNumber($number) { $this->number = $number; } + 34    public function setEmail($email) { $this->email = $email; } + 35    public function setMethod($method) { $this->method = $method; } + 36    public function setAddress($address) { $this->address = $address; } + 37    public function setTotalProducts($totalProducts) { $this->totalProducts = $totalProducts; } + 38    public function setTotalPrice($totalPrice) { $this->totalPrice = $totalPrice; } + 39    public function setPaymentStatus($status) { $this->paymentStatus = $status; } 40    public function setPlacedOn($placedOn) { $this->placedOn = $placedOn; } 41 42    public function setId($id) { - 43        $this->id = $id; - 44        return $this; + 43        $this->id = $id; + 44        return $this; 45    } 46}  @@ -646,7 +646,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Models/Product.php.html b/coverage/html/Models/Product.php.html index 84967f18..2f115b6c 100644 --- a/coverage/html/Models/Product.php.html +++ b/coverage/html/Models/Product.php.html @@ -292,18 +292,18 @@ 8    private $image; 9 10    // Getters - 11    public function getId() { return $this->id; } - 12    public function getName() { return $this->name; } - 13    public function getPrice() { return $this->price; } + 11    public function getId() { return $this->id; } + 12    public function getName() { return $this->name; } + 13    public function getPrice() { return $this->price; } 14    public function getImage() { return $this->image; } 15 16    // Setters - 17    public function setName($name) { $this->name = $name; } - 18    public function setPrice($price) { $this->price = $price; } - 19    public function setImage($image) { $this->image = $image; } + 17    public function setName($name) { $this->name = $name; } + 18    public function setPrice($price) { $this->price = $price; } + 19    public function setImage($image) { $this->image = $image; } 20 21    public function setId($id) { - 22        $this->id = $id; + 22        $this->id = $id; 23    } 24} @@ -316,7 +316,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Models/User.php.html b/coverage/html/Models/User.php.html index e6050f02..9771ecea 100644 --- a/coverage/html/Models/User.php.html +++ b/coverage/html/Models/User.php.html @@ -359,31 +359,31 @@ 9    private $userType; 10 11    public function __construct() { - 12        $this->userType = 'user'; + 12        $this->userType = 'user'; 13    } 14 15    // Getters - 16    public function getId() { return $this->id; } - 17    public function getName() { return $this->name; } - 18    public function getEmail() { return $this->email; } - 19    public function getUserType() { return $this->userType; } + 16    public function getId() { return $this->id; } + 17    public function getName() { return $this->name; } + 18    public function getEmail() { return $this->email; } + 19    public function getUserType() { return $this->userType; } 20 21    // Setters - 22    public function setName($name) { $this->name = $name; } - 23    public function setEmail($email) { $this->email = $email; } + 22    public function setName($name) { $this->name = $name; } + 23    public function setEmail($email) { $this->email = $email; } 24    public function setPassword($password) {  25        $this->password = password_hash($password, PASSWORD_DEFAULT); 26    } - 27    public function setUserType($userType) { $this->userType = $userType; } + 27    public function setUserType($userType) { $this->userType = $userType; } 28    public function setId($id) {  - 29        $this->id = $id;  - 30        return $this; + 29        $this->id = $id;  + 30        return $this; 31    } 32 33    public function exists($conn) { - 34        $stmt = $conn->prepare("SELECT id FROM users WHERE id = ?"); - 35        $stmt->execute([$this->id]); - 36        return $stmt->rowCount() > 0; + 34        $stmt = $conn->prepare("SELECT id FROM users WHERE id = ?"); + 35        $stmt->execute([$this->id]); + 36        return $stmt->rowCount() > 0; 37    } 38} @@ -396,7 +396,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/Models/dashboard.html b/coverage/html/Models/dashboard.html index 8e3ffc1b..38904d00 100644 --- a/coverage/html/Models/dashboard.html +++ b/coverage/html/Models/dashboard.html @@ -139,7 +139,7 @@

Project Risks

diff --git a/coverage/html/Models/index.html b/coverage/html/Models/index.html index 58d6b8cb..6aeaf21d 100644 --- a/coverage/html/Models/index.html +++ b/coverage/html/Models/index.html @@ -223,7 +223,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/autoload.php.html b/coverage/html/autoload.php.html index 612e66ce..2c52fbf4 100644 --- a/coverage/html/autoload.php.html +++ b/coverage/html/autoload.php.html @@ -67,7 +67,7 @@ - + @@ -77,7 +77,7 @@ - +
1<?php
2spl_autoload_register(function ($class) {
2spl_autoload_register(function ($class) {
3    // Convertir namespace a ruta de archivo
4    $base_dir = __DIR__ . '/';
5    $file = $base_dir . str_replace('\\', '/', $class) . '.php';
9        return true;
10    }
11    return false;
12}); 
12}); 
@@ -88,7 +88,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/dashboard.html b/coverage/html/dashboard.html index 5738da96..94d9c8af 100644 --- a/coverage/html/dashboard.html +++ b/coverage/html/dashboard.html @@ -59,8 +59,8 @@

Insufficient Coverage

Config\Database66% Controllers\OrderController81% - Controllers\AdminController83% Controllers\UserController83% + Controllers\AdminController84% @@ -77,8 +77,8 @@

Project Risks

- Controllers\AdminController80 - Controllers\OrderController33 + Controllers\AdminController78 + Controllers\OrderController36 Config\Database17 Controllers\UserController17 @@ -118,7 +118,7 @@

Insufficient Coverage

- validateImageName0% + validateImageName0% logout0% getId0% getPlacedOn0% @@ -126,21 +126,20 @@

Insufficient Coverage

__construct23% updatePaymentStatus40% deleteOrder40% - deleteMessage50% - deleteOrder57% - deleteUser57% - updateOrderStatus62% - handleImageDelete64% - deleteProduct69% + deleteMessage50% + deleteOrder57% + deleteUser57% + updateOrderStatus62% + handleImageDelete64% exists75% - addProduct76% - getAllUsers78% - getAllMessages80% + addProduct76% + deleteProduct76% + getAllUsers78% + getAllMessages80% getAllOrders82% - getSecureImagePath84% - getUserOrders85% + getUserOrders85% connect86% - updateProduct88% + updateProduct88% @@ -159,22 +158,21 @@

Project Risks

logout12 __construct11 - handleImageDelete10 + handleImageDelete10 getOrders7 - getSecureImagePath6 - updateProduct6 - deleteProduct5 - addProduct5 - getAllUsers3 - getAllMessages3 + updateProduct6 + addProduct5 + deleteProduct5 + getAllUsers3 + getAllMessages3 getAllOrders3 - getUserOrders3 + getUserOrders3 updatePaymentStatus2 deleteOrder2 - deleteMessage2 - deleteOrder2 - deleteUser2 - updateOrderStatus2 + deleteMessage2 + deleteOrder2 + deleteUser2 + updateOrderStatus2 connect2 @@ -185,7 +183,7 @@

Project Risks

@@ -222,7 +220,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([4,0,1,1,0,2,3,3,3,6,0,107], "Method Coverage")) + .datum(getCoverageDistributionData([4,0,1,1,0,2,3,2,4,5,1,107], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -272,7 +270,7 @@

Project Risks

chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[66.66666666666666,12,"Config\\Database<\/a>"],[83.25991189427313,62,"Controllers\\AdminController<\/a>"],[100,12,"Controllers\\ContactController<\/a>"],[81.16883116883116,28,"Controllers\\OrderController<\/a>"],[100,18,"Controllers\\ProductController<\/a>"],[100,3,"Controllers\\SearchController<\/a>"],[83.33333333333334,16,"Controllers\\UserController<\/a>"],[100,1,"Exceptions\\DatabaseException<\/a>"],[90.9090909090909,11,"Models\\Cart<\/a>"],[96,14,"Models\\Message<\/a>"],[95.65217391304348,22,"Models\\Order<\/a>"],[100,8,"Models\\Product<\/a>"],[100,11,"Models\\User<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[66.66666666666666,12,"Config\\Database<\/a>"],[84.27947598253274,63,"Controllers\\AdminController<\/a>"],[100,12,"Controllers\\ContactController<\/a>"],[81.76100628930818,31,"Controllers\\OrderController<\/a>"],[100,18,"Controllers\\ProductController<\/a>"],[100,3,"Controllers\\SearchController<\/a>"],[83.33333333333334,16,"Controllers\\UserController<\/a>"],[100,1,"Exceptions\\DatabaseException<\/a>"],[90.9090909090909,11,"Models\\Cart<\/a>"],[96,14,"Models\\Message<\/a>"],[95.65217391304348,22,"Models\\Order<\/a>"],[100,8,"Models\\Product<\/a>"],[100,11,"Models\\User<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -296,7 +294,7 @@

Project Risks

chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[23.076923076923077,4,"
Config\\Database::__construct<\/a>"],[100,5,"Config\\Database::setDefaultCredentials<\/a>"],[100,1,"Config\\Database::setCredentials<\/a>"],[86.66666666666667,2,"Config\\Database::connect<\/a>"],[100,1,"Controllers\\AdminController::__construct<\/a>"],[100,1,"Controllers\\AdminController::getDashboardData<\/a>"],[100,2,"Controllers\\AdminController::getTotalPendings<\/a>"],[100,2,"Controllers\\AdminController::getTotalCompleted<\/a>"],[100,1,"Controllers\\AdminController::getOrdersCount<\/a>"],[100,1,"Controllers\\AdminController::getProductsCount<\/a>"],[100,1,"Controllers\\AdminController::getUsersCount<\/a>"],[100,1,"Controllers\\AdminController::getAdminsCount<\/a>"],[100,1,"Controllers\\AdminController::getTotalAccounts<\/a>"],[100,1,"Controllers\\AdminController::getMessagesCount<\/a>"],[100,1,"Controllers\\AdminController::handleDatabaseError<\/a>"],[76.47058823529412,5,"Controllers\\AdminController::addProduct<\/a>"],[69.23076923076923,5,"Controllers\\AdminController::deleteProduct<\/a>"],[0,1,"Controllers\\AdminController::validateImageName<\/a>"],[84.61538461538461,6,"Controllers\\AdminController::getSecureImagePath<\/a>"],[64.70588235294117,8,"Controllers\\AdminController::handleImageDelete<\/a>"],[88.46153846153845,6,"Controllers\\AdminController::updateProduct<\/a>"],[100,2,"Controllers\\AdminController::getAllProducts<\/a>"],[100,2,"Controllers\\AdminController::getAllOrders<\/a>"],[62.5,2,"Controllers\\AdminController::updateOrderStatus<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteOrder<\/a>"],[78.57142857142857,3,"Controllers\\AdminController::getAllUsers<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteUser<\/a>"],[80,3,"Controllers\\AdminController::getAllMessages<\/a>"],[50,2,"Controllers\\AdminController::deleteMessage<\/a>"],[100,1,"Controllers\\ContactController::__construct<\/a>"],[100,1,"Controllers\\ContactController::createUser<\/a>"],[100,1,"Controllers\\ContactController::createMessage<\/a>"],[100,9,"Controllers\\ContactController::sendMessage<\/a>"],[100,1,"Controllers\\OrderController::__construct<\/a>"],[19.047619047619047,3,"Controllers\\OrderController::getOrders<\/a>"],[40,2,"Controllers\\OrderController::updatePaymentStatus<\/a>"],[40,2,"Controllers\\OrderController::deleteOrder<\/a>"],[82.35294117647058,3,"Controllers\\OrderController::getAllOrders<\/a>"],[100,5,"Controllers\\OrderController::createOrder<\/a>"],[100,1,"Controllers\\OrderController::getCartItems<\/a>"],[100,1,"Controllers\\OrderController::clearCart<\/a>"],[85,3,"Controllers\\OrderController::getUserOrders<\/a>"],[100,3,"Controllers\\OrderController::getAllProducts<\/a>"],[100,3,"Controllers\\OrderController::getAllUsers<\/a>"],[100,1,"Controllers\\OrderController::handleDatabaseError<\/a>"],[100,1,"Controllers\\ProductController::__construct<\/a>"],[100,3,"Controllers\\ProductController::getLatestProducts<\/a>"],[100,3,"Controllers\\ProductController::addToCart<\/a>"],[100,3,"Controllers\\ProductController::getAllProducts<\/a>"],[100,2,"Controllers\\ProductController::getCartItems<\/a>"],[100,2,"Controllers\\ProductController::updateCartQuantity<\/a>"],[100,2,"Controllers\\ProductController::deleteCartItem<\/a>"],[100,2,"Controllers\\ProductController::deleteAllCartItems<\/a>"],[100,1,"Controllers\\SearchController::__construct<\/a>"],[100,2,"Controllers\\SearchController::searchProducts<\/a>"],[100,1,"Controllers\\UserController::__construct<\/a>"],[100,1,"Controllers\\UserController::hashPassword<\/a>"],[100,1,"Controllers\\UserController::verifyPassword<\/a>"],[100,3,"Controllers\\UserController::registerUser<\/a>"],[100,4,"Controllers\\UserController::loginUser<\/a>"],[0,3,"Controllers\\UserController::logout<\/a>"],[100,2,"Controllers\\UserController::getUserById<\/a>"],[100,1,"Controllers\\UserController::register<\/a>"],[100,1,"Exceptions\\DatabaseException::__construct<\/a>"],[0,1,"Models\\Cart::getId<\/a>"],[100,1,"Models\\Cart::getUserId<\/a>"],[100,1,"Models\\Cart::getName<\/a>"],[100,1,"Models\\Cart::getPrice<\/a>"],[100,1,"Models\\Cart::getQuantity<\/a>"],[100,1,"Models\\Cart::getImage<\/a>"],[100,1,"Models\\Cart::setUserId<\/a>"],[100,1,"Models\\Cart::setName<\/a>"],[100,1,"Models\\Cart::setPrice<\/a>"],[100,1,"Models\\Cart::setQuantity<\/a>"],[100,1,"Models\\Cart::setImage<\/a>"],[100,1,"Models\\Message::getId<\/a>"],[100,1,"Models\\Message::getUserId<\/a>"],[100,1,"Models\\Message::getName<\/a>"],[100,1,"Models\\Message::getEmail<\/a>"],[100,1,"Models\\Message::getNumber<\/a>"],[100,1,"Models\\Message::getMessage<\/a>"],[100,1,"Models\\Message::setUserId<\/a>"],[100,1,"Models\\Message::setName<\/a>"],[100,1,"Models\\Message::setEmail<\/a>"],[100,1,"Models\\Message::setNumber<\/a>"],[100,1,"Models\\Message::setMessage<\/a>"],[75,1,"Models\\Message::exists<\/a>"],[100,1,"Models\\Message::save<\/a>"],[100,1,"Models\\Message::setId<\/a>"],[100,1,"Models\\Order::getId<\/a>"],[100,1,"Models\\Order::getUserId<\/a>"],[100,1,"Models\\Order::getName<\/a>"],[100,1,"Models\\Order::getNumber<\/a>"],[100,1,"Models\\Order::getEmail<\/a>"],[100,1,"Models\\Order::getMethod<\/a>"],[100,1,"Models\\Order::getAddress<\/a>"],[100,1,"Models\\Order::getTotalProducts<\/a>"],[100,1,"Models\\Order::getTotalPrice<\/a>"],[0,1,"Models\\Order::getPlacedOn<\/a>"],[100,1,"Models\\Order::getPaymentStatus<\/a>"],[100,1,"Models\\Order::setUserId<\/a>"],[100,1,"Models\\Order::setName<\/a>"],[100,1,"Models\\Order::setNumber<\/a>"],[100,1,"Models\\Order::setEmail<\/a>"],[100,1,"Models\\Order::setMethod<\/a>"],[100,1,"Models\\Order::setAddress<\/a>"],[100,1,"Models\\Order::setTotalProducts<\/a>"],[100,1,"Models\\Order::setTotalPrice<\/a>"],[100,1,"Models\\Order::setPaymentStatus<\/a>"],[100,1,"Models\\Order::setPlacedOn<\/a>"],[100,1,"Models\\Order::setId<\/a>"],[100,1,"Models\\Product::getId<\/a>"],[100,1,"Models\\Product::getName<\/a>"],[100,1,"Models\\Product::getPrice<\/a>"],[100,1,"Models\\Product::getImage<\/a>"],[100,1,"Models\\Product::setName<\/a>"],[100,1,"Models\\Product::setPrice<\/a>"],[100,1,"Models\\Product::setImage<\/a>"],[100,1,"Models\\Product::setId<\/a>"],[100,1,"Models\\User::__construct<\/a>"],[100,1,"Models\\User::getId<\/a>"],[100,1,"Models\\User::getName<\/a>"],[100,1,"Models\\User::getEmail<\/a>"],[100,1,"Models\\User::getUserType<\/a>"],[100,1,"Models\\User::setName<\/a>"],[100,1,"Models\\User::setEmail<\/a>"],[100,1,"Models\\User::setPassword<\/a>"],[100,1,"Models\\User::setUserType<\/a>"],[100,1,"Models\\User::setId<\/a>"],[100,1,"Models\\User::exists<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[23.076923076923077,4,"Config\\Database::__construct<\/a>"],[100,5,"Config\\Database::setDefaultCredentials<\/a>"],[100,1,"Config\\Database::setCredentials<\/a>"],[86.66666666666667,2,"Config\\Database::connect<\/a>"],[100,1,"Controllers\\AdminController::__construct<\/a>"],[100,1,"Controllers\\AdminController::getDashboardData<\/a>"],[100,3,"Controllers\\AdminController::getTotalPendings<\/a>"],[100,2,"Controllers\\AdminController::getTotalCompleted<\/a>"],[100,1,"Controllers\\AdminController::getOrdersCount<\/a>"],[100,1,"Controllers\\AdminController::getProductsCount<\/a>"],[100,1,"Controllers\\AdminController::getUsersCount<\/a>"],[100,1,"Controllers\\AdminController::getAdminsCount<\/a>"],[100,1,"Controllers\\AdminController::getTotalAccounts<\/a>"],[100,1,"Controllers\\AdminController::getMessagesCount<\/a>"],[100,1,"Controllers\\AdminController::handleDatabaseError<\/a>"],[76.47058823529412,5,"Controllers\\AdminController::addProduct<\/a>"],[76.92307692307693,5,"Controllers\\AdminController::deleteProduct<\/a>"],[0,1,"Controllers\\AdminController::validateImageName<\/a>"],[92.3076923076923,6,"Controllers\\AdminController::getSecureImagePath<\/a>"],[64.70588235294117,8,"Controllers\\AdminController::handleImageDelete<\/a>"],[88.46153846153845,6,"Controllers\\AdminController::updateProduct<\/a>"],[100,2,"Controllers\\AdminController::getAllProducts<\/a>"],[100,2,"Controllers\\AdminController::getAllOrders<\/a>"],[62.5,2,"Controllers\\AdminController::updateOrderStatus<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteOrder<\/a>"],[78.57142857142857,3,"Controllers\\AdminController::getAllUsers<\/a>"],[57.14285714285714,2,"Controllers\\AdminController::deleteUser<\/a>"],[80,3,"Controllers\\AdminController::getAllMessages<\/a>"],[50,2,"Controllers\\AdminController::deleteMessage<\/a>"],[100,1,"Controllers\\ContactController::__construct<\/a>"],[100,1,"Controllers\\ContactController::createUser<\/a>"],[100,1,"Controllers\\ContactController::createMessage<\/a>"],[100,9,"Controllers\\ContactController::sendMessage<\/a>"],[100,1,"Controllers\\OrderController::__construct<\/a>"],[19.047619047619047,3,"Controllers\\OrderController::getOrders<\/a>"],[40,2,"Controllers\\OrderController::updatePaymentStatus<\/a>"],[40,2,"Controllers\\OrderController::deleteOrder<\/a>"],[82.35294117647058,3,"Controllers\\OrderController::getAllOrders<\/a>"],[100,8,"Controllers\\OrderController::createOrder<\/a>"],[100,1,"Controllers\\OrderController::getCartItems<\/a>"],[100,1,"Controllers\\OrderController::clearCart<\/a>"],[85,3,"Controllers\\OrderController::getUserOrders<\/a>"],[100,3,"Controllers\\OrderController::getAllProducts<\/a>"],[100,3,"Controllers\\OrderController::getAllUsers<\/a>"],[100,1,"Controllers\\OrderController::handleDatabaseError<\/a>"],[100,1,"Controllers\\ProductController::__construct<\/a>"],[100,3,"Controllers\\ProductController::getLatestProducts<\/a>"],[100,3,"Controllers\\ProductController::addToCart<\/a>"],[100,3,"Controllers\\ProductController::getAllProducts<\/a>"],[100,2,"Controllers\\ProductController::getCartItems<\/a>"],[100,2,"Controllers\\ProductController::updateCartQuantity<\/a>"],[100,2,"Controllers\\ProductController::deleteCartItem<\/a>"],[100,2,"Controllers\\ProductController::deleteAllCartItems<\/a>"],[100,1,"Controllers\\SearchController::__construct<\/a>"],[100,2,"Controllers\\SearchController::searchProducts<\/a>"],[100,1,"Controllers\\UserController::__construct<\/a>"],[100,1,"Controllers\\UserController::hashPassword<\/a>"],[100,1,"Controllers\\UserController::verifyPassword<\/a>"],[100,3,"Controllers\\UserController::registerUser<\/a>"],[100,4,"Controllers\\UserController::loginUser<\/a>"],[0,3,"Controllers\\UserController::logout<\/a>"],[100,2,"Controllers\\UserController::getUserById<\/a>"],[100,1,"Controllers\\UserController::register<\/a>"],[100,1,"Exceptions\\DatabaseException::__construct<\/a>"],[0,1,"Models\\Cart::getId<\/a>"],[100,1,"Models\\Cart::getUserId<\/a>"],[100,1,"Models\\Cart::getName<\/a>"],[100,1,"Models\\Cart::getPrice<\/a>"],[100,1,"Models\\Cart::getQuantity<\/a>"],[100,1,"Models\\Cart::getImage<\/a>"],[100,1,"Models\\Cart::setUserId<\/a>"],[100,1,"Models\\Cart::setName<\/a>"],[100,1,"Models\\Cart::setPrice<\/a>"],[100,1,"Models\\Cart::setQuantity<\/a>"],[100,1,"Models\\Cart::setImage<\/a>"],[100,1,"Models\\Message::getId<\/a>"],[100,1,"Models\\Message::getUserId<\/a>"],[100,1,"Models\\Message::getName<\/a>"],[100,1,"Models\\Message::getEmail<\/a>"],[100,1,"Models\\Message::getNumber<\/a>"],[100,1,"Models\\Message::getMessage<\/a>"],[100,1,"Models\\Message::setUserId<\/a>"],[100,1,"Models\\Message::setName<\/a>"],[100,1,"Models\\Message::setEmail<\/a>"],[100,1,"Models\\Message::setNumber<\/a>"],[100,1,"Models\\Message::setMessage<\/a>"],[75,1,"Models\\Message::exists<\/a>"],[100,1,"Models\\Message::save<\/a>"],[100,1,"Models\\Message::setId<\/a>"],[100,1,"Models\\Order::getId<\/a>"],[100,1,"Models\\Order::getUserId<\/a>"],[100,1,"Models\\Order::getName<\/a>"],[100,1,"Models\\Order::getNumber<\/a>"],[100,1,"Models\\Order::getEmail<\/a>"],[100,1,"Models\\Order::getMethod<\/a>"],[100,1,"Models\\Order::getAddress<\/a>"],[100,1,"Models\\Order::getTotalProducts<\/a>"],[100,1,"Models\\Order::getTotalPrice<\/a>"],[0,1,"Models\\Order::getPlacedOn<\/a>"],[100,1,"Models\\Order::getPaymentStatus<\/a>"],[100,1,"Models\\Order::setUserId<\/a>"],[100,1,"Models\\Order::setName<\/a>"],[100,1,"Models\\Order::setNumber<\/a>"],[100,1,"Models\\Order::setEmail<\/a>"],[100,1,"Models\\Order::setMethod<\/a>"],[100,1,"Models\\Order::setAddress<\/a>"],[100,1,"Models\\Order::setTotalProducts<\/a>"],[100,1,"Models\\Order::setTotalPrice<\/a>"],[100,1,"Models\\Order::setPaymentStatus<\/a>"],[100,1,"Models\\Order::setPlacedOn<\/a>"],[100,1,"Models\\Order::setId<\/a>"],[100,1,"Models\\Product::getId<\/a>"],[100,1,"Models\\Product::getName<\/a>"],[100,1,"Models\\Product::getPrice<\/a>"],[100,1,"Models\\Product::getImage<\/a>"],[100,1,"Models\\Product::setName<\/a>"],[100,1,"Models\\Product::setPrice<\/a>"],[100,1,"Models\\Product::setImage<\/a>"],[100,1,"Models\\Product::setId<\/a>"],[100,1,"Models\\User::__construct<\/a>"],[100,1,"Models\\User::getId<\/a>"],[100,1,"Models\\User::getName<\/a>"],[100,1,"Models\\User::getEmail<\/a>"],[100,1,"Models\\User::getUserType<\/a>"],[100,1,"Models\\User::setName<\/a>"],[100,1,"Models\\User::setEmail<\/a>"],[100,1,"Models\\User::setPassword<\/a>"],[100,1,"Models\\User::setUserType<\/a>"],[100,1,"Models\\User::setId<\/a>"],[100,1,"Models\\User::exists<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/html/index.html b/coverage/html/index.html index 48b45be0..5c8d7692 100644 --- a/coverage/html/index.html +++ b/coverage/html/index.html @@ -44,13 +44,13 @@ Total
-
- 85.57% covered (warning) +
+ 86.00% covered (warning)
-
85.57%
-
593 / 693
+
86.00%
+
602 / 700
82.31% covered (warning) @@ -100,13 +100,13 @@ Controllers
-
- 86.43% covered (warning) +
+ 86.95% covered (warning)
-
86.43%
-
484 / 560
+
86.95%
+
493 / 567
69.49% covered (warning) @@ -230,7 +230,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/coverage/html/index.php.html b/coverage/html/index.php.html index 9874b318..8e64febc 100644 --- a/coverage/html/index.php.html +++ b/coverage/html/index.php.html @@ -92,7 +92,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 22:05:08 CET 2024. + Generated by php-code-coverage 9.2.32 using PHP 8.2.12 and PHPUnit 9.6.22 at Wed Dec 11 23:15:41 CET 2024.

diff --git a/reports/mutations/infection.html b/reports/mutations/infection.html index ac3dd2b5..edf70a70 100644 --- a/reports/mutations/infection.html +++ b/reports/mutations/infection.html @@ -12,7 +12,7 @@ app.addEventListener('theme-changed', updateTheme); updateTheme(); - document.getElementsByTagName('mutation-test-report-app').item(0).report = {"schemaVersion":"1","thresholds":{"high":90,"low":50},"files":{"Config\/Database.php":{"language":"php","source":"setDefaultCredentials();\r\n return;\r\n }\r\n\r\n $envPath = __DIR__ . '\/..\/..\/.env';\r\n \r\n if (file_exists($envPath)) {\r\n $env = parse_ini_file($envPath);\r\n if ($env !== false) {\r\n $this->host = $env['DB_HOST'];\r\n $this->user = $env['DB_USER'];\r\n $this->password = $env['DB_PASSWORD'];\r\n $this->database = $env['DB_NAME'];\r\n return;\r\n }\r\n }\r\n\r\n $this->setDefaultCredentials();\r\n }\r\n\r\n private function setDefaultCredentials(): void\r\n {\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n }\r\n\r\n public function setCredentials(string $host, string $user, string $password, string $database): void\r\n {\r\n $this->host = $host;\r\n $this->user = $user;\r\n $this->password = $password;\r\n $this->database = $database;\r\n }\r\n\r\n public function connect() {\r\n try {\r\n $conn = new \\PDO(\r\n \"mysql:host={$this->host};dbname={$this->database}\",\r\n $this->user,\r\n $this->password,\r\n array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\")\r\n );\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch(\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n throw new DatabaseException(\r\n \"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(),\r\n $e->getCode(),\r\n $e\r\n );\r\n }\r\n }\r\n} ","mutants":[{"id":"70f1a9a59c136dc0d10a0f0a6c1697e9","mutatorName":"TrueValue","replacement":"public function __construct(bool $useEnv = false)","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":13,"column":5},"end":{"line":13,"column":55}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"6e33f7a90aec2dd3bafe8e4e439e6df3","mutatorName":"LogicalNot","replacement":"if ($useEnv) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":14,"column":9},"end":{"line":14,"column":24}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.012, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\nfopen(C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\.env): Failed to open stream: Permission denied\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php:113\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php:20\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:14\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["a76b01946547645afdff37bedb7a60d8"],"testsCompleted":1},{"id":"669ea3810b5da00a195baa730423ebbf","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":15,"column":13},"end":{"line":15,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.719, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\nFailed asserting that null matches expected 'test_host'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\n\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["02fbcb9d639939cd105b73916f225638"],"testsCompleted":2},{"id":"e1590fd490676ae96b38f1f60eaddf07","mutatorName":"Ternary","replacement":"$this->host = getenv('DB_HOST') ? 'db' : getenv('DB_HOST');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":37,"column":9},"end":{"line":37,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.704, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'test_host'\n+'db'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\n\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["02fbcb9d639939cd105b73916f225638"],"testsCompleted":2},{"id":"ac150f0f10afad8a9d133140b5b51473","mutatorName":"Ternary","replacement":"$this->user = getenv('DB_USER') ? 'root' : getenv('DB_USER');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":38,"column":9},"end":{"line":38,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 398 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.717, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_valores_por_defecto_cuando_no_hay_env\nFailed asserting that false matches expected 'root'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:58\n\nFAILURES!\r\nTests: 3, Assertions: 4, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["699053407dfadfed887cd7fe49d05704"],"testsCompleted":3},{"id":"2b951f552d97bcf2549e46804adbbdd0","mutatorName":"Ternary","replacement":"$this->password = getenv('DB_PASSWORD') ? '123456' : getenv('DB_PASSWORD');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":39,"column":9},"end":{"line":39,"column":61}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"62a742f983e86a68b6abd4ea9883de4a","mutatorName":"Ternary","replacement":"$this->database = getenv('DB_NAME') ? 'tienda_bd' : getenv('DB_NAME');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":40,"column":9},"end":{"line":40,"column":60}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"a87a35d49977e33c6b280db307f1f05d","mutatorName":"PublicVisibility","replacement":"protected function connect()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":51,"column":5},"end":{"line":51,"column":32}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.019, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\nFailed asserting that exception of type \"Error\" matches expected exception \"Exceptions\\DatabaseException\". Message was: \"Call to protected method Config\\Database::connect() from scope Tests\\Unit\\Config\\DatabaseTest\" at\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:18\n.\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["a76b01946547645afdff37bedb7a60d8"],"testsCompleted":1},{"id":"c98cd08563143260c5b320d7c78d4e1b","mutatorName":"ArrayItemRemoval","replacement":"$conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array());","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":57,"column":17},"end":{"line":57,"column":73}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"019dc92121994ab88079699df3104e75","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error de conexi\u00f3n: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"bbe2dc76e2b8b26fc5ada51ba5a5c280","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"3f6d9e7a1e32c9f34d4700f42fdd4024","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error de conexi\u00f3n: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"d9e21d473ce4762b7918183ad5c73f44","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"105f009b665fcf6459812bb31e716ba4","mutatorName":"Throw_","replacement":"new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":63,"column":13},"end":{"line":67,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.717, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\nFailed asserting that exception of type \"Exceptions\\DatabaseException\" is thrown.\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["a76b01946547645afdff37bedb7a60d8"],"testsCompleted":1},{"id":"e3fc12ceee3690e94399dad1355ee1ab","mutatorName":"Concat","replacement":"throw new DatabaseException($e->getMessage() . \"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":64,"column":17},"end":{"line":64,"column":78}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"7c750a88ac3855fb5d0279d429e3d6cc","mutatorName":"ConcatOperandRemoval","replacement":"throw new DatabaseException($e->getMessage(), $e->getCode(), $e);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":64,"column":17},"end":{"line":64,"column":78}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"9010c6395295030139fd9d6d72d4d25f","mutatorName":"ConcatOperandRemoval","replacement":"throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":64,"column":17},"end":{"line":64,"column":78}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0}]},"Controllers\/AdminController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function getDashboardData() {\r\n $data = [];\r\n \r\n \/\/ Obtener total pendientes\r\n $data['total_pendings'] = $this->getTotalPendings();\r\n $data['total_completed'] = $this->getTotalCompleted();\r\n $data['orders_count'] = $this->getOrdersCount();\r\n $data['products_count'] = $this->getProductsCount();\r\n $data['users_count'] = $this->getUsersCount();\r\n $data['admins_count'] = $this->getAdminsCount();\r\n $data['total_accounts'] = $this->getTotalAccounts();\r\n $data['messages_count'] = $this->getMessagesCount();\r\n\r\n return $data;\r\n }\r\n\r\n private function getTotalPendings() {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n $stmt->execute();\r\n $total = 0;\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;\r\n }\r\n\r\n private function getTotalCompleted() {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n $stmt->execute();\r\n $total = 0;\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;\r\n }\r\n\r\n private function getOrdersCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getProductsCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `products`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getUsersCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getAdminsCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getTotalAccounts() {\r\n $query = \"SELECT COUNT(*) as count FROM `users`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getMessagesCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `message`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function handleDatabaseError($e) {\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n\r\n public function addProduct($postData, $files) {\r\n try {\r\n $product = new Product();\r\n $product->setName($postData['name']);\r\n $product->setPrice($postData['price']);\r\n $product->setImage($files['image']['name']);\r\n\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n \r\n if($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n\r\n if($files['image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\r\n }\r\n }\r\n\r\n public function deleteProduct($id) {\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen\r\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\r\n $stmt->execute([$id]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n \r\n if($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\r\n if(file_exists($imagePath)) {\r\n unlink($imagePath);\r\n }\r\n }\r\n \r\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\r\n if($stmt->execute([$id])) {\r\n return ['success' => true, 'message' => 'Producto eliminado'];\r\n }\r\n \r\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\r\n } catch (\\Exception $e) {\r\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\r\n }\r\n }\r\n\r\n private function validateImageName($imageName) {\r\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\r\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\r\n }\r\n\r\n private function getSecureImagePath($imageName) {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\r\n }\r\n\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\r\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n throw new \\Exception('Tipo de archivo no permitido');\r\n }\r\n\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n $stmt->execute([$imageName]);\r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n private function handleImageDelete($imageName) {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n return false;\r\n }\r\n\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n $stmt->execute([$imageName]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n\r\n if (!$result) {\r\n return false;\r\n }\r\n\r\n \/\/ Construir y validar la ruta\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n return false;\r\n }\r\n\r\n \/\/ Eliminar el archivo si existe\r\n if (file_exists($fullPath)) {\r\n return unlink($fullPath);\r\n }\r\n\r\n return false;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function updateProduct($postData, $files) {\r\n try {\r\n $product = new Product();\r\n $product->setId($postData['update_p_id']);\r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n \r\n if(!empty($files['update_image']['name'])) {\r\n if($files['update_image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {\r\n $this->handleImageDelete($postData['update_old_image']);\r\n }\r\n\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \r\n \/\/ Subir nueva imagen\r\n move_uploaded_file(\r\n $files['update_image']['tmp_name'], \r\n self::UPLOAD_PATH . $newImageName\r\n );\r\n \r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\r\n }\r\n \r\n if($stmt->execute($params)) {\r\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\r\n }\r\n \r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en updateProduct: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n }\r\n }\r\n\r\n public function getAllProducts() {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n }\r\n\r\n public function getAllOrders() {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n }\r\n\r\n public function updateOrderStatus($orderId, $status) {\r\n try {\r\n $order = new Order();\r\n $order->setId($orderId);\r\n $order->setPaymentStatus($status);\r\n \r\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n\r\n public function deleteOrder($orderId) {\r\n try {\r\n $order = new Order();\r\n $order->setId($orderId);\r\n \r\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\r\n return $stmt->execute([$order->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n\r\n public function getAllUsers() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n \r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }\r\n return $users;\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function deleteUser($userId) {\r\n try {\r\n $user = new User();\r\n $user->setId($userId);\r\n \r\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\r\n return $stmt->execute([$user->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n\r\n public function getAllMessages() {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\r\n $messages = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);\r\n $message->setNumber($row['number']);\r\n $messages[] = $message;\r\n }\r\n return $messages;\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function deleteMessage($messageId) {\r\n try {\r\n $query = \"DELETE FROM `message` WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n return $stmt->execute([$messageId]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n} ","mutants":[{"id":"9268c86e87530f1be2a3a1f4930e7bc8","mutatorName":"PublicVisibility","replacement":"protected function getDashboardData()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":20,"column":5},"end":{"line":20,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\nError: Call to protected method Controllers\\AdminController::getDashboardData() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["0035c38ba38c88bdf071f30dece5b1ed"],"testsCompleted":1},{"id":"8e01d41461f7f48498b19f862cda109a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":38,"column":9},"end":{"line":38,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"2ba8f3f92d7008139d7efb42dc740aee","mutatorName":"DecrementInteger","replacement":"$total = -1;","description":"Decrements an integer value with 1.","location":{"start":{"line":39,"column":9},"end":{"line":39,"column":20}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 249.0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"c76cf46f28958b2adec3ef79a7d5b1b4","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":40,"column":9},"end":{"line":45,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"63f2761aae7532d14bf76e82d734fe18","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":42,"column":13},"end":{"line":42,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"fb89c59fae5dcd39dfca6916a15c5ff9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":43,"column":13},"end":{"line":43,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"039005443122fd7fdd182b4e2072ec35","mutatorName":"Assignment","replacement":"$total = $order->getTotalPrice();","description":"Replaces examples of augmented or compound (shorter way to apply an arithmetic or bitwise operation)\nassignment operators, i.e. `+=`, `*=`, `.=`, etc., with a plain assignment operator `=`.","location":{"start":{"line":44,"column":13},"end":{"line":44,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 150.0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"1de56833dc515070e173dfe3a42798b8","mutatorName":"PlusEqual","replacement":"$total -= $order->getTotalPrice();","description":"Replaces an addition assignment operator (`+=`) with a subtraction assignment operator (`-=`).","location":{"start":{"line":44,"column":13},"end":{"line":44,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that -250.0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"cc5512198ad2f2bdc62821920602c98a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":51,"column":9},"end":{"line":51,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"705f3822c66619b4c1acb701c9c48ee8","mutatorName":"DecrementInteger","replacement":"$total = -1;","description":"Decrements an integer value with 1.","location":{"start":{"line":52,"column":9},"end":{"line":52,"column":20}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that 499.0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"047624d7bedda4e8530c3acd7730323d","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":53,"column":9},"end":{"line":58,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that 0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"3731d3205a7570e522b3e4d10dc024cf","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":55,"column":13},"end":{"line":55,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"3ebd88f9af7146467d8879aa2af1394c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":56,"column":13},"end":{"line":56,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that 0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"2b6d9acc43135a39e9bae65459e27dfe","mutatorName":"Assignment","replacement":"$total = $order->getTotalPrice();","description":"Replaces examples of augmented or compound (shorter way to apply an arithmetic or bitwise operation)\nassignment operators, i.e. `+=`, `*=`, `.=`, etc., with a plain assignment operator `=`.","location":{"start":{"line":57,"column":13},"end":{"line":57,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that 300.0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"eb55e771d2cfd572c5c90c22c866dcfa","mutatorName":"PlusEqual","replacement":"$total -= $order->getTotalPrice();","description":"Replaces an addition assignment operator (`+=`) with a subtraction assignment operator (`-=`).","location":{"start":{"line":57,"column":13},"end":{"line":57,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that -500.0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"a81698271bc62030a53edd88773859f8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":65,"column":9},"end":{"line":65,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["0035c38ba38c88bdf071f30dece5b1ed","cbbd507874ef939f3d552fb1d2778eaf"],"killedBy":[],"testsCompleted":0},{"id":"3fab74bfa71ca69f0e31b2e9a46900b6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":72,"column":9},"end":{"line":72,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["de9e276f8f5c747f061eb9509676c029","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"7e18e379eec1d04f021a95539f8f328f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":79,"column":9},"end":{"line":79,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["0035c38ba38c88bdf071f30dece5b1ed","3db6122e521f4175962773195c0ef118"],"killedBy":[],"testsCompleted":0},{"id":"ddc05dfb9923466d85d33bf296a9dd4d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":86,"column":9},"end":{"line":86,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["182f23aa48d798ca2b59ec5170288af1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"687abaca57f82e377208a2a128657666","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":93,"column":9},"end":{"line":93,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["0035c38ba38c88bdf071f30dece5b1ed","e79034ed9db001614c8a06b08fe29564"],"killedBy":[],"testsCompleted":0},{"id":"2876a47c88acaaf55e212ca6eb7402c9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":100,"column":9},"end":{"line":100,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["0035c38ba38c88bdf071f30dece5b1ed","04797ba6285e7536bc1672ee1f2993d1"],"killedBy":[],"testsCompleted":0},{"id":"dca0bc79e19877b332615df0b15bb18b","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en la base de datos: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":105,"column":9},"end":{"line":105,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["1fcbaae12f7aa2a9842563778effa4b8"],"killedBy":[],"testsCompleted":0},{"id":"98cfec04725a011635d0d098aaf3aaf1","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":105,"column":9},"end":{"line":105,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["1fcbaae12f7aa2a9842563778effa4b8"],"killedBy":[],"testsCompleted":0},{"id":"6ee182952402c95a0595a9b66f206264","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en la base de datos: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":105,"column":9},"end":{"line":105,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["1fcbaae12f7aa2a9842563778effa4b8"],"killedBy":[],"testsCompleted":0},{"id":"1a1347f050e28476532b3f345b603c06","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":105,"column":9},"end":{"line":105,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["1fcbaae12f7aa2a9842563778effa4b8"],"killedBy":[],"testsCompleted":0},{"id":"009585acd4957166e0ab7a0b364b7481","mutatorName":"Throw_","replacement":"new \\Exception(\"Error al procesar la solicitud\");","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":106,"column":9},"end":{"line":106,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............F\nNotice: fwrite(): Write of 1047 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleDatabaseError\nFailed asserting that exception of type \"Exception\" is thrown.\n\nFAILURES!\r\nTests: 13, Assertions: 34, Failures: 1.\r\n","coveredBy":["1fcbaae12f7aa2a9842563778effa4b8"],"killedBy":["1fcbaae12f7aa2a9842563778effa4b8"],"testsCompleted":13},{"id":"263e70ae76d8ef7f6d5855267d05b3ef","mutatorName":"PublicVisibility","replacement":"protected function addProduct($postData, $files)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":109,"column":5},"end":{"line":109,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.E\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nError: Call to protected method Controllers\\AdminController::addProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"5ddbd7e53df891b8c2d39fa89533028d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":112,"column":13},"end":{"line":112,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2300 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"ec8c9986bc94ef381cb8c9d8a88494dc","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":113,"column":13},"end":{"line":113,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"6e644d625f4b6a78e9394a34a9e582ec","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":114,"column":13},"end":{"line":114,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"2883aae97a5c89f1a57e1f512c20ca78","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"fd1e500d9a5b74cc18d6515fd7a5c8fb","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2300 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"dd863802096499567ae8833b5d39f5d4","mutatorName":"GreaterThan","replacement":"if ($stmt->rowCount() >= 0) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":120,"column":13},"end":{"line":120,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.F\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"2954240e4f3b31e8a491d83830f603ca","mutatorName":"GreaterThanNegotiation","replacement":"if ($stmt->rowCount() <= 0) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":120,"column":13},"end":{"line":120,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.F\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"bc38efb317976094d98ce865d7190e77","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El producto ya existe'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":121,"column":17},"end":{"line":121,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........................F\nNotice: fwrite(): Write of 2191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:573\n\nFAILURES!\r\nTests: 28, Assertions: 53, Failures: 1.\r\n","coveredBy":["29b79fb297244e4a16f3feec06d710f8"],"killedBy":["29b79fb297244e4a16f3feec06d710f8"],"testsCompleted":28},{"id":"b8adac4a0bbac0bc16711b9ebe581a6a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El producto ya existe'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":121,"column":17},"end":{"line":121,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........................E\nNotice: fwrite(): Write of 2199 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:573\n\nERRORS!\r\nTests: 28, Assertions: 52, Errors: 1.\r\n","coveredBy":["29b79fb297244e4a16f3feec06d710f8"],"killedBy":["29b79fb297244e4a16f3feec06d710f8"],"testsCompleted":28},{"id":"565e022dff1e7ec8ad322b7469b306a2","mutatorName":"GreaterThan","replacement":"if ($files['image']['size'] >= 2000000) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":124,"column":13},"end":{"line":124,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"bb1633da5b1bd575e1a6901991503dae","mutatorName":"GreaterThanNegotiation","replacement":"if ($files['image']['size'] <= 2000000) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":124,"column":13},"end":{"line":124,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.F\nNotice: fwrite(): Write of 298 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"b207bcacb55d68b9bb0af11383745c7b","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":125,"column":17},"end":{"line":125,"column":105}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW 1 \/ 1 (100%)\nNotice: fwrite(): Write of 63 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.010, Memory: 8.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 1, Assertions: 0, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7"],"killedBy":[],"testsCompleted":1},{"id":"c9cc0fbb0a8fe3c9e50ac6799f04a950","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":125,"column":17},"end":{"line":125,"column":105}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW 1 \/ 1 (100%)\nNotice: fwrite(): Write of 63 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.009, Memory: 8.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 1, Assertions: 0, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7"],"killedBy":[],"testsCompleted":1},{"id":"c531cb66355b04f5d8f291403533233a","mutatorName":"ArrayItemRemoval","replacement":"if ($stmt->execute([$product->getPrice(), $product->getImage()])) {","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":129,"column":13},"end":{"line":129,"column":100}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"f8b8f170eec073934c5361f57270db78","mutatorName":"Concat","replacement":"move_uploaded_file($files['image']['tmp_name'], $product->getImage() . self::UPLOAD_PATH);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":130,"column":17},"end":{"line":130,"column":107}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"4eeab42854d758685f950a4c882727e3","mutatorName":"ConcatOperandRemoval","replacement":"move_uploaded_file($files['image']['tmp_name'], $product->getImage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":130,"column":17},"end":{"line":130,"column":107}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2301 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"fcceccfe0a010d05b52ff10386a94113","mutatorName":"ConcatOperandRemoval","replacement":"move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":130,"column":17},"end":{"line":130,"column":107}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2301 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"44f59feddb3467cee20dae19aa28ce0a","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":130,"column":17},"end":{"line":130,"column":107}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":31},{"id":"3c48e36861ec94f710db7a7ff4d19b26","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":131,"column":17},"end":{"line":131,"column":94}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.F\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"431b89b35ec518e47a82dff5540bf5fa","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Producto a\u00f1adido exitosamente!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":131,"column":17},"end":{"line":131,"column":94}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.E\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"7446e72a2486d8c86da54089080bf490","mutatorName":"PublicVisibility","replacement":"protected function deleteProduct($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":139,"column":5},"end":{"line":139,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW....E\nNotice: fwrite(): Write of 511 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\nError: Call to protected method Controllers\\AdminController::deleteProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:127\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 6, Assertions: 14, Errors: 1, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":["09d8bcdc9cfda619b9c89a29648d2d8e"],"testsCompleted":6},{"id":"5080244b35202031a16ecb1bc26c0f9d","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":143,"column":13},"end":{"line":143,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":31},{"id":"d2d4520869e809b1679a2dd0214d62eb","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":143,"column":13},"end":{"line":143,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2316 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.067, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":31},{"id":"b6202d3b0d41cfaf9c9539dd598c355b","mutatorName":"Concat","replacement":"$imagePath = $image_data['image'] . self::UPLOAD_PATH;","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":147,"column":17},"end":{"line":147,"column":71}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW....F\nNotice: fwrite(): Write of 507 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:129\n\nFAILURES!\r\nTests: 6, Assertions: 15, Failures: 1, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":["09d8bcdc9cfda619b9c89a29648d2d8e"],"testsCompleted":6},{"id":"ddc6dd1b31f9a7cb1698463bdf0125b1","mutatorName":"ConcatOperandRemoval","replacement":"$imagePath = $image_data['image'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":147,"column":17},"end":{"line":147,"column":71}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":31},{"id":"6fbaed755ea492fb4e4e196acfa11adf","mutatorName":"ConcatOperandRemoval","replacement":"$imagePath = self::UPLOAD_PATH;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":147,"column":17},"end":{"line":147,"column":71}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":31},{"id":"6243c5e3ee3cb28e7cdd184c45104cbe","mutatorName":"ArrayItemRemoval","replacement":"if ($stmt->execute([])) {","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":154,"column":13},"end":{"line":154,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2308 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":31},{"id":"ee6234673ca18845c8ae55b75ba5f777","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => 'Producto eliminado'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":155,"column":17},"end":{"line":155,"column":79}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW....F\nNotice: fwrite(): Write of 510 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:129\n\nFAILURES!\r\nTests: 6, Assertions: 15, Failures: 1, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":["09d8bcdc9cfda619b9c89a29648d2d8e"],"testsCompleted":6},{"id":"00afa02918f7e7291aade0f3449dcad5","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Producto eliminado'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":155,"column":17},"end":{"line":155,"column":79}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW....E\nNotice: fwrite(): Write of 511 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:129\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 6, Assertions: 14, Errors: 1, Warnings: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":["09d8bcdc9cfda619b9c89a29648d2d8e"],"testsCompleted":6},{"id":"a76a4c602b4fc9b9af15926748a04fd8","mutatorName":"LogicalNot","replacement":"if (empty($imageName) || is_string($imageName)) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":172,"column":13},"end":{"line":172,"column":63}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................F\nNotice: fwrite(): Write of 1861 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.066, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\nFailed asserting that false is not false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\n\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1.\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7","4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"testsCompleted":24},{"id":"2f18b46dc4a2e7f56fb671e35115caf2","mutatorName":"LogicalOr","replacement":"if (empty($imageName) && !is_string($imageName)) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":172,"column":13},"end":{"line":172,"column":63}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7","4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":[],"testsCompleted":0},{"id":"c2cf35a9e7495068ddb107c11115fe49","mutatorName":"UnwrapStrToLower","replacement":"$extension = pathinfo($imageName, PATHINFO_EXTENSION);","description":"Replaces a `strtolower` function call with its first operand. For example:\n\n```php\n$x = strtolower('Hello!');\n```\n\nWill be mutated to:\n\n```php\n$x = 'Hello!';\n```","location":{"start":{"line":177,"column":13},"end":{"line":177,"column":79}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7","4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":[],"testsCompleted":0},{"id":"0079bfffa2feee13d15eef348bd62f10","mutatorName":"LogicalNot","replacement":"if (in_array($extension, self::ALLOWED_EXTENSIONS)) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":178,"column":13},"end":{"line":178,"column":67}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................F\nNotice: fwrite(): Write of 1858 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\nFailed asserting that false is not false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\n\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1.\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7","4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"testsCompleted":24},{"id":"f8946f171022ce6bcf8429dd67350d14","mutatorName":"Throw_","replacement":"new \\Exception('Tipo de archivo no permitido');","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":179,"column":17},"end":{"line":179,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........................E\nNotice: fwrite(): Write of 1960 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension\nError: Call to a member function execute() on bool\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:173\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:516\n\nERRORS!\r\nTests: 25, Assertions: 49, Errors: 1.\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":["da270c190fd61906ead367a1ea0887d7"],"testsCompleted":25},{"id":"d93e13317201f68c432c565c42cb2ffc","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":184,"column":13},"end":{"line":184,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":[],"testsCompleted":0},{"id":"376db4dead7a186e7481a8768d33b500","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":184,"column":13},"end":{"line":184,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":[],"testsCompleted":0},{"id":"ed3546b9821718d3545a6fcabf20ecd4","mutatorName":"LogicalNot","replacement":"if ($stmt->fetch()) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":185,"column":13},"end":{"line":185,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................F\nNotice: fwrite(): Write of 1858 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\nFailed asserting that false is not false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\n\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1.\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"testsCompleted":24},{"id":"6d7c5a45a3ffee116c7868f419c4bd71","mutatorName":"Concat","replacement":"return $imageName . self::UPLOAD_PATH;","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":189,"column":13},"end":{"line":189,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":[],"testsCompleted":0},{"id":"d31f6192e6109296107ce0e91dd58b25","mutatorName":"ConcatOperandRemoval","replacement":"return $imageName;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":189,"column":13},"end":{"line":189,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":[],"testsCompleted":0},{"id":"a3e31c169896037c4735deb0d4bb95f0","mutatorName":"ConcatOperandRemoval","replacement":"return self::UPLOAD_PATH;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":189,"column":13},"end":{"line":189,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................F\nNotice: fwrite(): Write of 1854 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\nFailed asserting that '..\/..\/uploaded_img\/' contains \"test.jpg\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:504\n\nFAILURES!\r\nTests: 24, Assertions: 49, Failures: 1.\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"testsCompleted":24},{"id":"0834422a38caa4a87cbd70e213b1a599","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en getSecureImagePath: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":191,"column":13},"end":{"line":191,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":[],"testsCompleted":0},{"id":"da4fdba4d50f5f644cce852d692bcd1b","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":191,"column":13},"end":{"line":191,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":[],"testsCompleted":0},{"id":"93a6e0f7409d1561cdddd2bef395b131","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en getSecureImagePath: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":191,"column":13},"end":{"line":191,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":[],"testsCompleted":0},{"id":"72acd1642b7cd7e152494090ab80bea6","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":191,"column":13},"end":{"line":191,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":[],"testsCompleted":0},{"id":"fe6b280cc4b2b85c15ce9715f9f5ac1f","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":192,"column":13},"end":{"line":192,"column":26}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........................F\nNotice: fwrite(): Write of 1960 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:518\n\nFAILURES!\r\nTests: 25, Assertions: 50, Failures: 1.\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":["da270c190fd61906ead367a1ea0887d7"],"testsCompleted":25},{"id":"a15760870bf298af4559a23ccd81e158","mutatorName":"LogicalNot","replacement":"if (empty($imageName) || is_string($imageName)) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":199,"column":13},"end":{"line":199,"column":63}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","18df9e78a83ffa99f0e870e79d11a7ef","d736e3db7bd2dbf25459d31155b47535","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"0439334cf02dceda052bba074a0fe28b","mutatorName":"LogicalOr","replacement":"if (empty($imageName) && !is_string($imageName)) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":199,"column":13},"end":{"line":199,"column":63}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW..........................E\nNotice: fwrite(): Write of 2147 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName\nError: Call to a member function execute() on bool\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:192\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:546\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 28, Assertions: 51, Errors: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","18df9e78a83ffa99f0e870e79d11a7ef","d736e3db7bd2dbf25459d31155b47535","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["18df9e78a83ffa99f0e870e79d11a7ef"],"testsCompleted":28},{"id":"e2c9afb3a3a204c653fb00e55080d5f4","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":200,"column":17},"end":{"line":200,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..........................F\nNotice: fwrite(): Write of 2123 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:548\n\nFAILURES!\r\nTests: 27, Assertions: 52, Failures: 1.\r\n","coveredBy":["18df9e78a83ffa99f0e870e79d11a7ef"],"killedBy":["18df9e78a83ffa99f0e870e79d11a7ef"],"testsCompleted":27},{"id":"5477fb8bd3025e0cd7ca8344dd158c10","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":205,"column":13},"end":{"line":205,"column":42}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.059, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"7f397de3bf5acfd17d014adc7041ccd3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":205,"column":13},"end":{"line":205,"column":42}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"999e9e89e694cd7f0a1afe07ac9357e5","mutatorName":"LogicalNot","replacement":"if ($result) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":208,"column":13},"end":{"line":208,"column":28}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2316 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.057, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"f79b3c4f6698298606e0af37c73ef71a","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":209,"column":17},"end":{"line":209,"column":30}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.060, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"ada2dd5416d551f9b144d5972b416db9","mutatorName":"Concat","replacement":"$fullPath = realpath($result['image'] . self::UPLOAD_PATH);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":213,"column":13},"end":{"line":213,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.061, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"c72f6383d1ea9cd5687e3b78c1b39ad7","mutatorName":"ConcatOperandRemoval","replacement":"$fullPath = realpath($result['image']);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":213,"column":13},"end":{"line":213,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2308 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.059, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"3de8dbfbd1d3599967fd1301020ed35f","mutatorName":"ConcatOperandRemoval","replacement":"$fullPath = realpath(self::UPLOAD_PATH);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":213,"column":13},"end":{"line":213,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"8a73c86795d220381d2dee5b9771e355","mutatorName":"FalseValue","replacement":"if ($fullPath === true || strpos($fullPath, $uploadDir) !== 0) {","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.060, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"8b3e0bc8eb866bd8b84d8f5bcb610395","mutatorName":"Identical","replacement":"if ($fullPath !== false || strpos($fullPath, $uploadDir) !== 0) {","description":"Replaces an identical operator (`===`) with its counterpart the not identical operator (`!==`).","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"da8c8283c1d2fc7073c55dbe6bda44d1","mutatorName":"DecrementInteger","replacement":"if ($fullPath === false || strpos($fullPath, $uploadDir) !== -1) {","description":"Decrements an integer value with 1.","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"ced438af1a46939ce701e7a4812b8924","mutatorName":"NotIdentical","replacement":"if ($fullPath === false || strpos($fullPath, $uploadDir) === 0) {","description":"Replaces a not identical operator (`!==`) with its counterpart the not identical operator (`===`).","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"5b26132f573a6e91743e0154275c94ce","mutatorName":"LogicalOr","replacement":"if ($fullPath === false && strpos($fullPath, $uploadDir) !== 0) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"a59e91a8b1a2eca454c84ba089882f0c","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":218,"column":17},"end":{"line":218,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":31},{"id":"be2aae7f157e74c0e1b5c662f53d4de1","mutatorName":"PublicVisibility","replacement":"protected function updateProduct($postData, $files)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":233,"column":5},"end":{"line":233,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW..........E\nNotice: fwrite(): Write of 922 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nError: Call to protected method Controllers\\AdminController::updateProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 12, Assertions: 27, Errors: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"01db364515603a4af5fbb5bae942ed18","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":236,"column":13},"end":{"line":236,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"8ec059f2a5b2641fd18ca53953936246","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":237,"column":13},"end":{"line":237,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"1c6a50494d2de5a2edc6ec6ef3e669d5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":238,"column":13},"end":{"line":238,"column":59}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"75138b414c4ef3f28cea99f251614f7c","mutatorName":"LogicalNot","replacement":"if (empty($files['update_image']['name'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":240,"column":13},"end":{"line":240,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.....................F\nNotice: fwrite(): Write of 1736 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithoutImage\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:462\n\nFAILURES!\r\nTests: 23, Assertions: 44, Failures: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["6f545f29a2bbd15c0e463d582b40e0e6"],"testsCompleted":23},{"id":"4034084cbda66451b605c78dbede6351","mutatorName":"GreaterThan","replacement":"if ($files['update_image']['size'] >= 2000000) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":241,"column":17},"end":{"line":241,"column":63}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"142bed38666552cfc0d989601ca49b30","mutatorName":"GreaterThanNegotiation","replacement":"if ($files['update_image']['size'] <= 2000000) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":241,"column":17},"end":{"line":241,"column":63}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW..........F\nNotice: fwrite(): Write of 926 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:243\n\nFAILURES!\r\nTests: 12, Assertions: 28, Failures: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"0874fb3f756efb9281badc872df49181","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":242,"column":21},"end":{"line":242,"column":109}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......................F\nNotice: fwrite(): Write of 1793 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\n\nFAILURES!\r\nTests: 23, Assertions: 46, Failures: 1.\r\n","coveredBy":["57253b9d08a8f0a9941004a0ce8690f2"],"killedBy":["57253b9d08a8f0a9941004a0ce8690f2"],"testsCompleted":23},{"id":"989499613f393b5756dde5126c68e4cf","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":242,"column":21},"end":{"line":242,"column":109}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......................E\nNotice: fwrite(): Write of 1793 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\n\nERRORS!\r\nTests: 23, Assertions: 45, Errors: 1.\r\n","coveredBy":["57253b9d08a8f0a9941004a0ce8690f2"],"killedBy":["57253b9d08a8f0a9941004a0ce8690f2"],"testsCompleted":23},{"id":"f274b3048b09bbaa324820c7a4ccc819","mutatorName":"LogicalNot","replacement":"if (empty($postData['update_old_image'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":246,"column":17},"end":{"line":246,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"3746290b17dd81ad9de1c7abea8bd2bf","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":247,"column":21},"end":{"line":247,"column":77}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"6e541cebedfee3fd3c5fc60a9eaeb27d","mutatorName":"UnwrapStrToLower","replacement":"$extension = pathinfo($files['update_image']['name'], PATHINFO_EXTENSION);","description":"Replaces a `strtolower` function call with its first operand. For example:\n\n```php\n$x = strtolower('Hello!');\n```\n\nWill be mutated to:\n\n```php\n$x = 'Hello!';\n```","location":{"start":{"line":251,"column":17},"end":{"line":251,"column":103}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"4a75c939a9f5b679b9c3a24904967fa8","mutatorName":"Concat","replacement":"$newImageName = '.' . uniqid() . $extension;","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":252,"column":17},"end":{"line":252,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"caecaef7aeae6a9ed3409c1e2cad565e","mutatorName":"ConcatOperandRemoval","replacement":"$newImageName = '.' . $extension;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":252,"column":17},"end":{"line":252,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"47a14fdcf6f01920e8a4433b73efc0fd","mutatorName":"ConcatOperandRemoval","replacement":"$newImageName = uniqid() . $extension;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":252,"column":17},"end":{"line":252,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2308 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.058, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"b40ab9a8994478fba3a390a9a82c98dd","mutatorName":"Concat","replacement":"$newImageName = uniqid() . $extension . '.';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":252,"column":17},"end":{"line":252,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"1406e71c4187bc2f2f2628e6f4df73ee","mutatorName":"ConcatOperandRemoval","replacement":"$newImageName = uniqid() . '.';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":252,"column":17},"end":{"line":252,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"bf9d174074caaeff7ddab309eadb8a70","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":253,"column":17},"end":{"line":253,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"7fbcc3aa6c962b57a4f3690c7b5fc29d","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":256,"column":17},"end":{"line":259,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"453aa5615f25d64ed4a73c62aa1d50f3","mutatorName":"Concat","replacement":"move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":258,"column":21},"end":{"line":258,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"e5ba4b950d871d031e21fffadfcf490a","mutatorName":"ConcatOperandRemoval","replacement":"move_uploaded_file($files['update_image']['tmp_name'], $newImageName);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":258,"column":21},"end":{"line":258,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"5fd315223dd77c61d960a7a17e650ba1","mutatorName":"ConcatOperandRemoval","replacement":"move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":258,"column":21},"end":{"line":258,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.057, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"e97a992e439cfaefd157e4a8c969c2a9","mutatorName":"ArrayItemRemoval","replacement":"$params = [$product->getPrice(), $product->getImage(), $product->getId()];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":262,"column":17},"end":{"line":262,"column":112}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":31},{"id":"61767fd5e88e6af111069ea868921a31","mutatorName":"ArrayItemRemoval","replacement":"$params = [$product->getPrice(), $product->getId()];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":265,"column":17},"end":{"line":265,"column":90}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.............................. 31 \/ 31 (100%)\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6"],"killedBy":[],"testsCompleted":31},{"id":"75ae7b2034ff46e4d777be9542f3bab2","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => 'Producto actualizado exitosamente'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":269,"column":17},"end":{"line":269,"column":94}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW..........F\nNotice: fwrite(): Write of 925 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\n--\n\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:243\n\nFAILURES!\r\nTests: 12, Assertions: 28, Failures: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","6f545f29a2bbd15c0e463d582b40e0e6","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"3c26e92e46323b65dbba79cd5a6cf662","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Producto actualizado exitosamente'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":269,"column":17},"end":{"line":269,"column":94}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW..........E\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:243\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 12, Assertions: 27, Errors: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","6f545f29a2bbd15c0e463d582b40e0e6","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"abe708f0e132a5d8fb41c38b1989b9a8","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al actualizar el producto'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":272,"column":13},"end":{"line":272,"column":89}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............................F\nNotice: fwrite(): Write of 2285 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:597\n\nFAILURES!\r\nTests: 29, Assertions: 55, Failures: 1.\r\n","coveredBy":["fdc4d9a06f09a8929a91ed6665707728"],"killedBy":["fdc4d9a06f09a8929a91ed6665707728"],"testsCompleted":29},{"id":"c27f1c446b040b5b22b83d756748b81b","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al actualizar el producto'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":272,"column":13},"end":{"line":272,"column":89}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............................E\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.056, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:597\n\nERRORS!\r\nTests: 29, Assertions: 54, Errors: 1.\r\n","coveredBy":["fdc4d9a06f09a8929a91ed6665707728"],"killedBy":["fdc4d9a06f09a8929a91ed6665707728"],"testsCompleted":29},{"id":"315bdd8c4db25ad937b07a418ea01535","mutatorName":"PublicVisibility","replacement":"protected function getAllProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":279,"column":5},"end":{"line":279,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nError: Call to protected method Controllers\\AdminController::getAllProducts() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:212\n\nERRORS!\r\nTests: 10, Assertions: 23, Errors: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"25054787f98bffd796016090fab8083c","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":282,"column":9},"end":{"line":289,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nFailed asserting that actual size 0 matches expected size 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:215\n\nFAILURES!\r\nTests: 10, Assertions: 25, Failures: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"22232df88aa9f0b1662c3784659e4220","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":284,"column":13},"end":{"line":284,"column":41}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":[],"testsCompleted":0},{"id":"b562736e6c68b5f8fa295ff3f31844e8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":285,"column":13},"end":{"line":285,"column":45}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nFailed asserting that null matches expected 'Product 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:216\n\nFAILURES!\r\nTests: 10, Assertions: 26, Failures: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"40bc2bd68b9f13222515d4ec7e5ad187","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":286,"column":13},"end":{"line":286,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nFailed asserting that null matches expected 99.99.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:217\n\nFAILURES!\r\nTests: 10, Assertions: 27, Failures: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"7269100fe1a7ec047bb3a34809548420","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":287,"column":13},"end":{"line":287,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":[],"testsCompleted":0},{"id":"cf29ff4757b60864d2dcea8ca19d1105","mutatorName":"PublicVisibility","replacement":"protected function getAllOrders()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":293,"column":5},"end":{"line":293,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........E\nNotice: fwrite(): Write of 961 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nError: Call to protected method Controllers\\AdminController::getAllOrders() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:270\n\nERRORS!\r\nTests: 12, Assertions: 29, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"209e9c813a409874c46a6036666ea69a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":295,"column":9},"end":{"line":295,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"e8ccd9c7f5eeae468566c243f6635929","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":297,"column":9},"end":{"line":311,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 965 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nFailed asserting that actual size 0 matches expected size 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:273\n\nFAILURES!\r\nTests: 12, Assertions: 31, Failures: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"fa27cfc683ee001378101f79658bdd34","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":299,"column":13},"end":{"line":299,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"bb56bdaa22b3239e97c7b8cf1a96e261","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":300,"column":13},"end":{"line":300,"column":48}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"32b3cb3ac900d3d71ae24370a544517f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":301,"column":13},"end":{"line":301,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"dcf3242ff6c4d2005e4b574d0181768e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":302,"column":13},"end":{"line":302,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 965 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nFailed asserting that null matches expected 'Customer 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:274\n\nFAILURES!\r\nTests: 12, Assertions: 32, Failures: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"0f5819221c369a113fa9c7e65d64427d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":303,"column":13},"end":{"line":303,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"da4dc781e0e838a158b35b0f84febe38","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":304,"column":13},"end":{"line":304,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"ad4587e65ba55481a8ec04c633964c99","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":305,"column":13},"end":{"line":305,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"36164c0def7f1f0f8d5ed0e4c71aafa4","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":306,"column":13},"end":{"line":306,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"1615bf816d2d26120187f0bb174349a2","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":307,"column":13},"end":{"line":307,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 969 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nFailed asserting that null matches expected 199.98.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:275\n\nFAILURES!\r\nTests: 12, Assertions: 33, Failures: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"06956a0bdcc27ff7581b27735dce4d95","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":308,"column":13},"end":{"line":308,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.057, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"b394ffacfca9630f951d0ec413e786dc","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":309,"column":13},"end":{"line":309,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"efc21e8e235a149ce6bbd3f040ee7052","mutatorName":"PublicVisibility","replacement":"protected function updateOrderStatus($orderId, $status)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":315,"column":5},"end":{"line":315,"column":59}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\nError: Call to protected method Controllers\\AdminController::updateOrderStatus() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\n\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1.\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["9cf07fc703009bc41d2d6794677c2465"],"testsCompleted":3},{"id":"b43122c24201d9b481175e157c4db6c8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":318,"column":13},"end":{"line":318,"column":37}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":[],"testsCompleted":0},{"id":"b55314f9432eabdc92b948b37ac04667","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":319,"column":13},"end":{"line":319,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2290 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.060, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":[],"testsCompleted":0},{"id":"4bff481aff6a1a4c44ce7b7c6edc1d9d","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([$order->getId()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":322,"column":13},"end":{"line":322,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.055, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":[],"testsCompleted":0},{"id":"6b81d8c81fb90b2e27291d1fa053bb69","mutatorName":"PublicVisibility","replacement":"protected function deleteOrder($orderId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":329,"column":5},"end":{"line":329,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 548 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder\nError: Call to protected method Controllers\\AdminController::deleteOrder() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:141\n\nERRORS!\r\nTests: 6, Assertions: 16, Errors: 1.\r\n","coveredBy":["9f4d645aba7ebec46f8fa49817ad0027"],"killedBy":["9f4d645aba7ebec46f8fa49817ad0027"],"testsCompleted":6},{"id":"6c32afffc17501df3f048f0c13b687ea","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":332,"column":13},"end":{"line":332,"column":37}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["9f4d645aba7ebec46f8fa49817ad0027"],"killedBy":[],"testsCompleted":0},{"id":"00fcf2ab3b968d91f35a4a768cbf7e09","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":335,"column":13},"end":{"line":335,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.057, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["9f4d645aba7ebec46f8fa49817ad0027"],"killedBy":[],"testsCompleted":0},{"id":"6a8df75769836752a88f15c00540112d","mutatorName":"PublicVisibility","replacement":"protected function getAllUsers()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":342,"column":5},"end":{"line":342,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nError: Call to protected method Controllers\\AdminController::getAllUsers() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:108\n\nERRORS!\r\nTests: 4, Assertions: 8, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"10dc04ee54bf5ccb5c4afd6f0dcb23de","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":345,"column":13},"end":{"line":345,"column":30}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"aa014c7a4e8e588fabc396e198abc85f","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":348,"column":13},"end":{"line":355,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 403 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nFailed asserting that actual size 0 matches expected size 2.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:111\n\nFAILURES!\r\nTests: 4, Assertions: 10, Failures: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"2d3353492f5de65ddb50433525275239","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":350,"column":17},"end":{"line":350,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"a3edf7183c08e8eb6319e82fa6c7c6c2","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":351,"column":17},"end":{"line":351,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 407 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nFailed asserting that null matches expected 'Admin User'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:114\n\nFAILURES!\r\nTests: 4, Assertions: 13, Failures: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"7542d8bb45c1628c50406784f187a571","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":352,"column":17},"end":{"line":352,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 404 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nFailed asserting that null matches expected 'user@test.com'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\n\nFAILURES!\r\nTests: 4, Assertions: 14, Failures: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"5a33119c6534c7c84965fa57cc73f64e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":353,"column":17},"end":{"line":353,"column":55}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2285 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"4b31ec62fe3c2fe92d1fab21fccbd38f","mutatorName":"PublicVisibility","replacement":"protected function deleteUser($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":363,"column":5},"end":{"line":363,"column":42}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 609 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\nError: Call to protected method Controllers\\AdminController::deleteUser() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\n\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1.\r\n","coveredBy":["cff255228f49b624005b9e8e6a3187d2"],"killedBy":["cff255228f49b624005b9e8e6a3187d2"],"testsCompleted":7},{"id":"26bee14dbfbbb34940cd3c35262be0fa","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":366,"column":13},"end":{"line":366,"column":35}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["cff255228f49b624005b9e8e6a3187d2"],"killedBy":[],"testsCompleted":0},{"id":"9c55ad2f1f43bb57afb21e28026640f5","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":369,"column":13},"end":{"line":369,"column":53}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["cff255228f49b624005b9e8e6a3187d2"],"killedBy":[],"testsCompleted":0},{"id":"f214ab5d7166ae5b66e9927fd452be4a","mutatorName":"PublicVisibility","replacement":"protected function getAllMessages()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":376,"column":5},"end":{"line":376,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nError: Call to protected method Controllers\\AdminController::getAllMessages() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:176\n\nERRORS!\r\nTests: 8, Assertions: 18, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"93202e25adeed9a71da93793d1e68993","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":380,"column":13},"end":{"line":389,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nFailed asserting that actual size 0 matches expected size 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:179\n\nFAILURES!\r\nTests: 8, Assertions: 20, Failures: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"dd471ca8f70c948a088366d67b4701af","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":382,"column":17},"end":{"line":382,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":[],"testsCompleted":0},{"id":"6b0f005c9ae4e8becc5685ad2d7be3de","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":383,"column":17},"end":{"line":383,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":[],"testsCompleted":0},{"id":"7f25748e69bb172d91ec68d7819c929e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":384,"column":17},"end":{"line":384,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nFailed asserting that null matches expected 'Test message'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:180\n\nFAILURES!\r\nTests: 8, Assertions: 21, Failures: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"c236a0f5ae6faa358ae4d189bea78611","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":385,"column":17},"end":{"line":385,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":[],"testsCompleted":0},{"id":"d39ee764cd787dcc1f101b22dc23623a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":386,"column":17},"end":{"line":386,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nFailed asserting that null matches expected 'test@test.com'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:181\n\nFAILURES!\r\nTests: 8, Assertions: 22, Failures: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"68187fd1457a54f8a9f8b61a3804b569","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":387,"column":17},"end":{"line":387,"column":53}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":[],"testsCompleted":0},{"id":"5877096b8d843880c3dfa61527211744","mutatorName":"PublicVisibility","replacement":"protected function deleteMessage($messageId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":397,"column":5},"end":{"line":397,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 759 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage\nError: Call to protected method Controllers\\AdminController::deleteMessage() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:192\n\nERRORS!\r\nTests: 9, Assertions: 22, Errors: 1.\r\n","coveredBy":["111d21c767467e138a3e41568fbcceab"],"killedBy":["111d21c767467e138a3e41568fbcceab"],"testsCompleted":9},{"id":"dc0bd6c413bea4301639118845c92ec3","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":401,"column":13},"end":{"line":401,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["111d21c767467e138a3e41568fbcceab"],"killedBy":[],"testsCompleted":0}]},"Controllers\/ContactController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\r\n protected function createUser()\r\n {\r\n return new User();\r\n }\r\n\r\n protected function createMessage()\r\n {\r\n return new Message();\r\n }\r\n\r\n public function sendMessage($userData) {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n if (!isset($userData['user_id']) || !isset($userData['name']) || \r\n !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n if (!$user->exists($this->conn)) {\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }\r\n\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);\r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);\r\n $message->setMessage($userData['message']);\r\n\r\n if ($message->exists($this->conn)) { \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n}","mutants":[{"id":"d1d77da730c645e71c3a16d2dcde0691","mutatorName":"ProtectedVisibility","replacement":"private function createUser()","description":"Replaces the `protected` method visibility keyword with `private`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","5aeab43d6bb5e254f77e2aa5dac28edb"],"killedBy":[],"testsCompleted":0},{"id":"326bc1e50b62ca752229c3b73569a08d","mutatorName":"NewObject","replacement":"new User();\r\n return null;","description":"Replaces a newly instantiated object with `null` instead. The instantiation statement is kept in order\nto preserve potential side effects. Example:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n return new stdClass();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n new stdClass();\n return null;\n }\n}\n```\n","location":{"start":{"line":19,"column":9},"end":{"line":19,"column":27}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","5aeab43d6bb5e254f77e2aa5dac28edb"],"killedBy":[],"testsCompleted":0},{"id":"44ffffcf3fb0767550593ddcb4affb87","mutatorName":"ProtectedVisibility","replacement":"private function createMessage()","description":"Replaces the `protected` method visibility keyword with `private`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\nPHPUnit\\Framework\\MockObject\\MethodCannotBeConfiguredException: Trying to configure method \"createMessage\" which cannot be configured because it does not exist, has not been specified, is final, or is static\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:35\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["68e73fbb4670258440901c3a46e2064d"],"killedBy":["9ebb033692c3de0faab3cd111369f928"],"testsCompleted":1},{"id":"21f1ad6be65ee07e4f3d4fe00b5b7aea","mutatorName":"NewObject","replacement":"new Message();\r\n return null;","description":"Replaces a newly instantiated object with `null` instead. The instantiation statement is kept in order\nto preserve potential side effects. Example:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n return new stdClass();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n new stdClass();\n return null;\n }\n}\n```\n","location":{"start":{"line":24,"column":9},"end":{"line":24,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message\nFailed asserting that null is an instance of class \"Models\\Message\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:179\n\nFAILURES!\r\nTests: 8, Assertions: 14, Failures: 1.\r\n","coveredBy":["68e73fbb4670258440901c3a46e2064d"],"killedBy":["68e73fbb4670258440901c3a46e2064d"],"testsCompleted":8},{"id":"daf84e3955ef93066d1ce3fe135ed3c0","mutatorName":"PublicVisibility","replacement":"protected function sendMessage($userData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":27,"column":5},"end":{"line":27,"column":45}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"fe9367649c15baba6cef2eb4f993450b","mutatorName":"LogicalNot","replacement":"if (isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":30,"column":13},"end":{"line":30,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"aff65a440abf1765cf633f3eebc9cc36","mutatorName":"LogicalNot","replacement":"if (!isset($userData['user_id']) || isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":30,"column":13},"end":{"line":30,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"efaf2ddd305b7582882d60dd2ade8933","mutatorName":"LogicalOr","replacement":"if (!isset($userData['user_id']) && !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":30,"column":13},"end":{"line":30,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"ffe4471c5d89a51096037026d8c36449","mutatorName":"LogicalOr","replacement":"if ((!isset($userData['user_id']) || !isset($userData['name'])) && !isset($userData['email']) || !isset($userData['message'])) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":30,"column":13},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"9ead9cb3e6961d2c1bf2208f5d7fdc46","mutatorName":"LogicalOr","replacement":"if ((!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email'])) && !isset($userData['message'])) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":30,"column":13},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"da9e5951fd499b5eb9f525f1e16d12af","mutatorName":"LogicalNot","replacement":"if (!isset($userData['user_id']) || !isset($userData['name']) || isset($userData['email']) || !isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":31,"column":17},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"3a900415d5f02c6ea10eed7d70d7a563","mutatorName":"LogicalNot","replacement":"if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":31,"column":17},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"9a17629d6b94998b3d033c3f6c4c5b57","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Faltan campos requeridos'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":32,"column":17},"end":{"line":32,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["b488b34d4881115bec02ef8105e30716","b93f5bfed89d4ed88cd4c8765ceac045"],"killedBy":[],"testsCompleted":0},{"id":"3b92aac6e83e59d8f7769ce5c7cdf46a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Faltan campos requeridos'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":32,"column":17},"end":{"line":32,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["b488b34d4881115bec02ef8105e30716","b93f5bfed89d4ed88cd4c8765ceac045"],"killedBy":[],"testsCompleted":0},{"id":"797a8daa33090c10af0799f82262849d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":37,"column":13},"end":{"line":37,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"9029cff1b16e62a3c708a72fe5952461","mutatorName":"LogicalNot","replacement":"if ($user->exists($this->conn)) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":38,"column":13},"end":{"line":38,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"5d63f0a7753a559e19ac2b2c291fba6a","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Usuario no encontrado'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":39,"column":17},"end":{"line":39,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","966624d19ce2dba3bed3eccf1c0f956f"],"killedBy":[],"testsCompleted":0},{"id":"1d789e09cb9505b1f5125712fb5bd8ad","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Usuario no encontrado'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":39,"column":17},"end":{"line":39,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","966624d19ce2dba3bed3eccf1c0f956f"],"killedBy":[],"testsCompleted":0},{"id":"fad512c004d3d0e04c1a3d3e55cd30e6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":43,"column":13},"end":{"line":43,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setUserId\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"b0877614aadd4b9ffc10ae048f0f8b2e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":44,"column":13},"end":{"line":44,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setName\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"10e991df75b8d67dbd89c144af94637d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":45,"column":13},"end":{"line":45,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 895 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setEmail\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"946c2fbb735321cb9ee7cec323f0a413","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":46,"column":13},"end":{"line":46,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setNumber\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"9d4927fa3ed94d06f8383de4669352b3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":47,"column":13},"end":{"line":47,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 898 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setMessage\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"16a349d69a6eec1a153da7a7536e25cf","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => '\u00a1Mensaje ya enviado!'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":50,"column":17},"end":{"line":50,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 452 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\n\nFAILURES!\r\nTests: 4, Assertions: 7, Failures: 1.\r\n","coveredBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"killedBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"testsCompleted":4},{"id":"112d6201db25ea7829e0b0236dec23c4","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Mensaje ya enviado!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":50,"column":17},"end":{"line":50,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 452 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\n\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1.\r\n","coveredBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"killedBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"testsCompleted":4},{"id":"e62f4e3af08d6d884c1194aaada59089","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Mensaje enviado exitosamente!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":92}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["9ebb033692c3de0faab3cd111369f928"],"testsCompleted":1},{"id":"3aeb4804ec19a9853b58e2c748922f4a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Mensaje enviado exitosamente!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":92}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["9ebb033692c3de0faab3cd111369f928"],"testsCompleted":1},{"id":"996a72cab07496167c42526ee1bd7f87","mutatorName":"Concat","replacement":"error_log($userData['user_id'] . \"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1070 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"e3134f59e642cba1cfa2f45c7755ffc2","mutatorName":"ConcatOperandRemoval","replacement":"error_log($userData['user_id']);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"29deadb639a0292036d21dcb170c84bb","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"5053d4fa5a03673c7191c1386e99b466","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"f04179551a36e95ab710990fef6ce8b7","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al enviar mensaje'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":81}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\n\nFAILURES!\r\nTests: 5, Assertions: 9, Failures: 1.\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":["dadb1321b7b0db79872fdfdbe6115493"],"testsCompleted":5},{"id":"febbfc1aaa19c48addc652b10d4dcec5","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al enviar mensaje'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":81}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\n\nERRORS!\r\nTests: 5, Assertions: 8, Errors: 1.\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":["dadb1321b7b0db79872fdfdbe6115493"],"testsCompleted":5},{"id":"f9f89dfb155a35bb5b580c77ae656af4","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al enviar mensaje: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"dd145de5420bd7526e9840e9c18fb0ec","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"a4894786dc78c58bcf56951a62b940c6","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al enviar mensaje: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"eccdfbbcafc132dc0eaf227f3f65e9ad","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1070 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"e359f075d04152f5f530d91442aba870","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\n\nFAILURES!\r\nTests: 6, Assertions: 11, Failures: 1.\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":["76926558c21488fe35e209f0ecda409e"],"testsCompleted":6},{"id":"c3640ffbbccb8d607cb1c4b722c0b7cf","mutatorName":"Concat","replacement":"return ['success' => false, 'message' => $e->getMessage() . 'Error al enviar mensaje: '];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"9a1e00bbfa63587641ab92cc67698e91","mutatorName":"ConcatOperandRemoval","replacement":"return ['success' => false, 'message' => $e->getMessage()];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 629 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\nFailed asserting that 'Error de conexi\u00f3n' contains \"Error al enviar mensaje\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:153\n\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1.\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":["76926558c21488fe35e209f0ecda409e"],"testsCompleted":6},{"id":"59ba8d3ad85054d62810c011d429b78b","mutatorName":"ConcatOperandRemoval","replacement":"return ['success' => false, 'message' => 'Error al enviar mensaje: '];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"dac6a1694673b01ca662f87eb508ecf2","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al enviar mensaje: ' . $e->getMessage()];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 626 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\n\nERRORS!\r\nTests: 6, Assertions: 10, Errors: 1.\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":["76926558c21488fe35e209f0ecda409e"],"testsCompleted":6}]},"Controllers\/OrderController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function getOrders($userId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function updatePaymentStatus($orderId, $status) {\r\n try {\r\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$status, $orderId]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function deleteOrder($orderId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\r\n return $stmt->execute([$orderId]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function getAllOrders() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function createOrder($userData, $userId) {\r\n try {\r\n $order = new Order();\r\n $order->setUserId($userId);\r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);\r\n $order->setMethod($userData['method']);\r\n \r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if(empty($cartItems)) {\r\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n\r\n \/\/ Calcular total y preparar lista de productos\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n $cartTotal += ($item['price'] * $item['quantity']);\r\n }\r\n $totalProducts = implode(', ', $products);\r\n\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n $address = 'flat no. ' . $userData['flat'] . ', ' . \r\n $userData['street'] . ', ' . \r\n $userData['city'] . ', ' . \r\n $userData['country'] . ' - ' . \r\n $userData['pin_code'];\r\n \r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);\r\n $order->setTotalPrice($cartTotal);\r\n \r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?\");\r\n \r\n $stmt->execute([\r\n $order->getName(),\r\n $order->getNumber(),\r\n $order->getEmail(),\r\n $order->getMethod(),\r\n $order->getAddress(),\r\n $order->getTotalProducts(),\r\n $order->getTotalPrice()\r\n ]);\r\n\r\n if($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \r\n (user_id, name, number, email, method, address, \r\n total_products, total_price, placed_on) \r\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n\r\n $stmt->execute([\r\n $order->getUserId(),\r\n $order->getName(),\r\n $order->getNumber(),\r\n $order->getEmail(),\r\n $order->getMethod(),\r\n $order->getAddress(),\r\n $order->getTotalProducts(),\r\n $order->getTotalPrice(),\r\n date('d-M-Y')\r\n ]);\r\n\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }\r\n\r\n private function getCartItems($userId) {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n }\r\n\r\n private function clearCart($userId) {\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n }\r\n\r\n public function getUserOrders($userId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function getAllProducts() {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function getAllUsers() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }\r\n return $users;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n private function handleDatabaseError(\\Exception $e) {\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n }\r\n} ","mutants":[{"id":"b011449c4da94522d894f44b4e35c8d2","mutatorName":"PublicVisibility","replacement":"protected function getOrders($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos\nError: Call to protected method Controllers\\OrderController::getOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:206\n\nERRORS!\r\nTests: 7, Assertions: 24, Errors: 1.\r\n","coveredBy":["ceb6936c11cf19bb44e528fa327f0416"],"killedBy":["ceb6936c11cf19bb44e528fa327f0416"],"testsCompleted":7},{"id":"3c3303dfaec40c4c283864648498c68d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":40,"column":13},"end":{"line":40,"column":44}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["ceb6936c11cf19bb44e528fa327f0416"],"killedBy":[],"testsCompleted":0},{"id":"376fe58a9944ac94091c137db0669cc3","mutatorName":"PublicVisibility","replacement":"protected function updatePaymentStatus($orderId, $status)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":45,"column":5},"end":{"line":45,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["ac9ac5f42f33e350edbcf6e51247ed95","40ff0078972e38dca8cfb4be5e49a3b0"],"killedBy":[],"testsCompleted":0},{"id":"18790cd45a04fd179430da33248c85d6","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([$orderId]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":48,"column":13},"end":{"line":48,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["ac9ac5f42f33e350edbcf6e51247ed95","40ff0078972e38dca8cfb4be5e49a3b0"],"killedBy":[],"testsCompleted":0},{"id":"04c5eb4b77676b6be0e9be886b2e4afe","mutatorName":"PublicVisibility","replacement":"protected function deleteOrder($orderId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":55,"column":5},"end":{"line":55,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["9112c9fc2d730bc2c02af9b6785500ea","452ca6af2bdb570f2ff036e996e62a49"],"killedBy":[],"testsCompleted":0},{"id":"2a04db4fe40e9e3fe5fd61c379172419","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["9112c9fc2d730bc2c02af9b6785500ea","452ca6af2bdb570f2ff036e996e62a49"],"killedBy":[],"testsCompleted":0},{"id":"ea0713e667ff03d193c73d4fdaa741cf","mutatorName":"PublicVisibility","replacement":"protected function getAllOrders()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":65,"column":5},"end":{"line":65,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 477 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nError: Call to protected method Controllers\\OrderController::getAllOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:170\n\nERRORS!\r\nTests: 5, Assertions: 15, Errors: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":5},{"id":"2a3e272b05aa6680a03345b0eadec829","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":68,"column":13},"end":{"line":68,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 473 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 5, Assertions: 20, Failures: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":5},{"id":"6186dc3d07fdef24bdd14d2445f69f5b","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":70,"column":13},"end":{"line":80,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 477 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:172\n\nFAILURES!\r\nTests: 5, Assertions: 16, Failures: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":5},{"id":"f83a7bf6248093c49ef34b67456d9add","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":72,"column":17},"end":{"line":72,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 476 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nFailed asserting that null is identical to 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:174\n\nFAILURES!\r\nTests: 5, Assertions: 18, Failures: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":5},{"id":"2ecbba998eb69367aebd9e2c4997f326","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":73,"column":17},"end":{"line":73,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"63339aaba74d3bc63b63ffee7e53047f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":74,"column":17},"end":{"line":74,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"9c7783eb0fec9f1683e73d4e2eded606","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":75,"column":17},"end":{"line":75,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"4ec6c815dbb9e143be7f84e78336281e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":76,"column":17},"end":{"line":76,"column":53}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"d146853ec7b77a224aea23a78966ac5c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":77,"column":17},"end":{"line":77,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"00a895b8ce075e2190d79f4040c55e3b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":78,"column":17},"end":{"line":78,"column":60}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"d5e11b4668eb45ef6faa793852e08922","mutatorName":"PublicVisibility","replacement":"protected function createOrder($userData, $userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":88,"column":5},"end":{"line":88,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"9b3756eeebb9217633a87d62b08f971a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":91,"column":13},"end":{"line":91,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"b1dacc82b0366d563fbe3f65804bf044","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":92,"column":13},"end":{"line":92,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"c81b57cc7b850c3940a9fc157136690f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":93,"column":13},"end":{"line":93,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"768c3265ca65df234b6e9301f84a0df8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"7456245cd85c1dc349fc90f55b09a1b5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":95,"column":13},"end":{"line":95,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"a39fb0a67987198b60c48fcfbc265687","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El carrito est\u00e1 vac\u00edo'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":100,"column":17},"end":{"line":100,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","9b1d437f68a23ef8f0c60f232232f51c"],"killedBy":[],"testsCompleted":0},{"id":"41e93e1ea4ea74c3ee38e530fdd2cb2d","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El carrito est\u00e1 vac\u00edo'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":100,"column":17},"end":{"line":100,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","9b1d437f68a23ef8f0c60f232232f51c"],"killedBy":[],"testsCompleted":0},{"id":"4864853802c662221aafad11be037132","mutatorName":"DecrementInteger","replacement":"$cartTotal = -1;","description":"Decrements an integer value with 1.","location":{"start":{"line":104,"column":13},"end":{"line":104,"column":28}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"6cb2ef0fcc7c989180e6284122974011","mutatorName":"Foreach_","replacement":"foreach (array() as $item) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":106,"column":13},"end":{"line":109,"column":43}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"5b018e8e45ffc648e8dfb54cec222837","mutatorName":"Concat","replacement":"$products[] = ' (' . $item['name'] . $item['quantity'] . ')';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"4a7288c4e031ba003913b1310b09c738","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = ' (' . $item['quantity'] . ')';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"f8a22a07e3246964ade1def47a058576","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = $item['name'] . $item['quantity'] . ')';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"3bfc4f7581256396a50d30ea2279c674","mutatorName":"Concat","replacement":"$products[] = $item['name'] . $item['quantity'] . ' (' . ')';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"9707a8b061580fea2ec066447bebf335","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = $item['name'] . ' (' . ')';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"8cfc91738f3ce0bb3736bb1960a7fcc1","mutatorName":"Concat","replacement":"$products[] = $item['name'] . ' (' . ')' . $item['quantity'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"7b6d63b026880ffe689f8b23335041f7","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = $item['name'] . ' (' . $item['quantity'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":107,"column":17},"end":{"line":107,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"be012c96af255b6ba84457ca39f961b4","mutatorName":"Multiplication","replacement":"$cartTotal += $item['price'] \/ $item['quantity'];","description":"Replaces a multiplication operator (`*`) with a division assignment operator (`\/`).","location":{"start":{"line":108,"column":17},"end":{"line":108,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"3fb2febe8b4338b7990049066458edf5","mutatorName":"Assignment","replacement":"$cartTotal = $item['price'] * $item['quantity'];","description":"Replaces examples of augmented or compound (shorter way to apply an arithmetic or bitwise operation)\nassignment operators, i.e. `+=`, `*=`, `.=`, etc., with a plain assignment operator `=`.","location":{"start":{"line":108,"column":17},"end":{"line":108,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"9b7883394674fd02eb624de461c9cd5d","mutatorName":"PlusEqual","replacement":"$cartTotal -= $item['price'] * $item['quantity'];","description":"Replaces an addition assignment operator (`+=`) with a subtraction assignment operator (`-=`).","location":{"start":{"line":108,"column":17},"end":{"line":108,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"9b398a193d013ba21684a2b86586eac4","mutatorName":"Concat","replacement":"$address = $userData['flat'] . 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":113,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"013b30a0da6ea8ec0fe8643fd6435ee1","mutatorName":"ConcatOperandRemoval","replacement":"$address = $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":113,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"7f982910b711bca610e0cff3f0673fc8","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":113,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"3a604fee10f750b89f7fa3913646d333","mutatorName":"Concat","replacement":"$address = 'flat no. ' . ', ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":113,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"7b72a6089d2e32f3df0f03e28bba5a34","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":113,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"7515866503b6fd2c251dc7527bccf8bc","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":114,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"3d7b8c05c522806c3fed24d08622112a","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":114,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1349 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"28c104fc482d5ec94d0c04772399ece7","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":114,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"67812039ebd70b83dee4f7db8fd5bd30","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":114,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"1bdaf7c40653c36598fb0ba2b52e66bb","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":115,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"27fea7a3f90d0f3042e0de54d9d834fa","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":115,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"3c19071459cc68de2450279be897f62f","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":115,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"1830e570b47255d83e90ab4e59141ae4","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":115,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"1964210d8241b385f7ac541d4ff31007","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":116,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"52fefe6f174ba48a762a12ab08279bf2","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":116,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1345 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"f7a7d1e21f49ce9dada2a81475a780ea","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":116,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"816da19ef9bdc77337e2f0e86f5fe2d2","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":116,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"c73413e955786cb95eb558b6c0b6ac0e","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - ';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":113,"column":13},"end":{"line":117,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"059557ea19007936c86fe55c36ab470d","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":113,"column":13},"end":{"line":117,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"b03a456019620536caad8b847d79f76a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":120,"column":13},"end":{"line":120,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1345 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"91285ea422daff37b319ac7e060db81e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":121,"column":13},"end":{"line":121,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"d12c6b92de40260398b92f2e1fde2c9f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":122,"column":13},"end":{"line":122,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"be5500396e420f16cdf6fc6835f5de3d","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":130,"column":13},"end":{"line":138,"column":29}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"ee782cea56cb9451d5487dd51d44ea3a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":130,"column":13},"end":{"line":138,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"8a34967c034c93926c88a37a9586def3","mutatorName":"GreaterThan","replacement":"if ($stmt->rowCount() >= 0) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":140,"column":13},"end":{"line":140,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"cd8f7e535c248f06f26afb58e2905ccc","mutatorName":"GreaterThanNegotiation","replacement":"if ($stmt->rowCount() <= 0) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":140,"column":13},"end":{"line":140,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"4188af4bb3e0eeeb00e69c0ddd8725a6","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => '\u00a1Pedido ya realizado!'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":141,"column":17},"end":{"line":141,"column":84}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..........F\nNotice: fwrite(): Write of 987 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.073, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:356\n\nFAILURES!\r\nTests: 11, Assertions: 41, Failures: 1.\r\n","coveredBy":["d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["d274c529f48ebd0c0d2e7e82410e3415"],"testsCompleted":11},{"id":"cf7c2e1bf80b5b60aa0c8d5be959bd61","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Pedido ya realizado!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":141,"column":17},"end":{"line":141,"column":84}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..........E\nNotice: fwrite(): Write of 983 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.062, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:356\n\nERRORS!\r\nTests: 11, Assertions: 40, Errors: 1.\r\n","coveredBy":["d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["d274c529f48ebd0c0d2e7e82410e3415"],"testsCompleted":11},{"id":"a91c41d00232a9f218262ae0afb1bbae","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":150,"column":13},"end":{"line":160,"column":29}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":[],"testsCompleted":0},{"id":"c2b1133448f80f2b1a381332c607473f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":150,"column":13},"end":{"line":160,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"c158bb166f3db513f8fc8a99d450a1e3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":163,"column":13},"end":{"line":163,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"prepare\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"5fda7b8cc7276118c3d7907b0d19fd53","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":165,"column":13},"end":{"line":165,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"fd88b2d22e0b77a20ebec86ee55657a5","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Pedido realizado con \u00e9xito!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":165,"column":13},"end":{"line":165,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 166 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"b50e6ae07e7deb6dd712f837c6cb6d99","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al crear orden: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":167,"column":13},"end":{"line":167,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1349 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"3c11b5878a7d152d62729b40332ee816","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":167,"column":13},"end":{"line":167,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"9fa34bdcd5df39a5f7bbf4876a40688c","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al crear orden: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":167,"column":13},"end":{"line":167,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"8bd7abd3167ab9a0758da8505e0c5fea","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":167,"column":13},"end":{"line":167,"column":68}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"6bf6f2326cc140a5b06893e1a9d461c1","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al procesar el pedido'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":168,"column":13},"end":{"line":168,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 1071 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:382\n\nFAILURES!\r\nTests: 12, Assertions: 45, Failures: 1.\r\n","coveredBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"testsCompleted":12},{"id":"95559f16e340769fae10e9c2cdb5106e","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al procesar el pedido'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":168,"column":13},"end":{"line":168,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........E\nNotice: fwrite(): Write of 1071 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:382\n\nERRORS!\r\nTests: 12, Assertions: 44, Errors: 1.\r\n","coveredBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":["7a701a7b1ab59a11ed7dcb7f27545ae6"],"testsCompleted":12},{"id":"6509f15c3eab8e7b9611e67c423481d1","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":174,"column":9},"end":{"line":174,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"ca39a715faa9d0a5a2006ab7e8f40545","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":174,"column":9},"end":{"line":174,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"b38b986ec8157dd76ecb79b843e3c206","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":180,"column":9},"end":{"line":180,"column":35}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":[],"testsCompleted":0},{"id":"047368d7e4f61251a2b6c445973fd7fe","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":180,"column":9},"end":{"line":180,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"941b475cec4cf9d9dbb5ae962d834adc","mutatorName":"PublicVisibility","replacement":"protected function getUserOrders($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":183,"column":5},"end":{"line":183,"column":45}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 256 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.058, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nError: Call to protected method Controllers\\OrderController::getUserOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\n\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"859526849cb009b47f2088fafb5662c5","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":186,"column":13},"end":{"line":186,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\n\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"93a438cdb5c5e6e5ef568cac2ed69411","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":186,"column":13},"end":{"line":186,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"0f6739e88d6e9fb7f918b4f0c8b6b27e","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":188,"column":13},"end":{"line":201,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\n\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"618e7dcbf72a5bb789f1f1ff891e105c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":190,"column":17},"end":{"line":190,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nFailed asserting that null is identical to 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:104\n\nFAILURES!\r\nTests: 2, Assertions: 7, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"af20fb69e1d6a58db87b5727c3e929cd","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":191,"column":17},"end":{"line":191,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"be2fbc1b2308bdd41a236c7b4762f8dd","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":192,"column":17},"end":{"line":192,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"2fdc59c4c6260beaecd28868969a85d9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":193,"column":17},"end":{"line":193,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"78f6a5441df22d8f71538243b3cf25d6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":194,"column":17},"end":{"line":194,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"4d2ed5b39148d04b890ac6d150c9eec9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":195,"column":17},"end":{"line":195,"column":53}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1362 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"8ddb395fee35c4fd24b3ee521aab846c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":196,"column":17},"end":{"line":196,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.074, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"68055ee0fb8a77d14040a87501bfe3de","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":197,"column":17},"end":{"line":197,"column":60}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.073, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"df374ed406b8167e7739b295d41b6d1d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":198,"column":17},"end":{"line":198,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.073, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"3a058dce154d3e7fef4370976ee2eda1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":199,"column":17},"end":{"line":199,"column":56}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1362 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"48ba7a6a5dc66a80fa38d1a639256bbc","mutatorName":"PublicVisibility","replacement":"protected function getAllProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":209,"column":5},"end":{"line":209,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Controllers\\OrderController::getAllProducts() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\n\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1.\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"9d80d12b5ac79353ffb2fcd3cc313443","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":213,"column":13},"end":{"line":219,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 745 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:249\n\nFAILURES!\r\nTests: 8, Assertions: 27, Failures: 1.\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"b3523a8d4333aa4dc574594b99e7ee03","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":215,"column":17},"end":{"line":215,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nFailed asserting that null matches expected 'Producto 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:251\n\nFAILURES!\r\nTests: 8, Assertions: 29, Failures: 1.\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"fedcaa39c29f56feb66771d97c161070","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":216,"column":17},"end":{"line":216,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":[],"testsCompleted":0},{"id":"5daf99b7c8e7cbcd5e1d321d77ea2b3b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":217,"column":17},"end":{"line":217,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":[],"testsCompleted":0},{"id":"c5c5cd664d21470f80f760de0e349e51","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":222,"column":13},"end":{"line":222,"column":44}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108"],"killedBy":[],"testsCompleted":0},{"id":"aa72cdb15e85a190fbfa486db198712c","mutatorName":"PublicVisibility","replacement":"protected function getAllUsers()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":227,"column":5},"end":{"line":227,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Controllers\\OrderController::getAllUsers() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\n\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1.\r\n","coveredBy":["b388534ee189eeb5ea1ebdd33ff1fb04","aca810d1d7530667d800dd6115dd2020"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"b62f6c17d2fa71ee786e7e87424dbace","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":230,"column":13},"end":{"line":230,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 36, Failures: 1.\r\n","coveredBy":["aca810d1d7530667d800dd6115dd2020"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"513a58e648fb94ee32807931092fd380","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":232,"column":13},"end":{"line":238,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:283\n\nFAILURES!\r\nTests: 9, Assertions: 32, Failures: 1.\r\n","coveredBy":["aca810d1d7530667d800dd6115dd2020"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"c621bec953214d238bf0ef7aa6f32157","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":234,"column":17},"end":{"line":234,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 819 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nFailed asserting that null matches expected 'Usuario 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:285\n\nFAILURES!\r\nTests: 9, Assertions: 34, Failures: 1.\r\n","coveredBy":["aca810d1d7530667d800dd6115dd2020"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"fc2ca19b2806dff024c57ee4123cee6b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":235,"column":17},"end":{"line":235,"column":48}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["aca810d1d7530667d800dd6115dd2020"],"killedBy":[],"testsCompleted":0},{"id":"671e04ef2bfa2b1876e81502f93638e2","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":236,"column":17},"end":{"line":236,"column":55}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["aca810d1d7530667d800dd6115dd2020"],"killedBy":[],"testsCompleted":0},{"id":"c84475f048c27b09d2f02a2207707b0b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":241,"column":13},"end":{"line":241,"column":44}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["b388534ee189eeb5ea1ebdd33ff1fb04"],"killedBy":[],"testsCompleted":0},{"id":"8d75847587b04f1b182ebb3b1584390b","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en la base de datos: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":247,"column":9},"end":{"line":247,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","b388534ee189eeb5ea1ebdd33ff1fb04","ceb6936c11cf19bb44e528fa327f0416"],"killedBy":[],"testsCompleted":0},{"id":"2e1449a024b9562be6ca1e9664ccbaef","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":247,"column":9},"end":{"line":247,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","b388534ee189eeb5ea1ebdd33ff1fb04","ceb6936c11cf19bb44e528fa327f0416"],"killedBy":[],"testsCompleted":0},{"id":"6b8566df3a4bf3e4bec194b1c1e88ffa","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en la base de datos: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":247,"column":9},"end":{"line":247,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","b388534ee189eeb5ea1ebdd33ff1fb04","ceb6936c11cf19bb44e528fa327f0416"],"killedBy":[],"testsCompleted":0},{"id":"77b935f0b948482ff3c0db15bc18b228","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":247,"column":9},"end":{"line":247,"column":69}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1330 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","b388534ee189eeb5ea1ebdd33ff1fb04","ceb6936c11cf19bb44e528fa327f0416"],"killedBy":[],"testsCompleted":0}]},"Controllers\/ProductController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function getLatestProducts($limit = 6) {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n $stmt->execute();\r\n \r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function addToCart($userId, $productData) {\r\n try {\r\n $cart = new Cart();\r\n $cart->setUserId($userId);\r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);\r\n $cart->setImage($productData['product_image']);\r\n \r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n \r\n if($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \r\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n \r\n $stmt->execute([\r\n $cart->getUserId(),\r\n $cart->getName(),\r\n $cart->getPrice(),\r\n $cart->getQuantity(),\r\n $cart->getImage()\r\n ]);\r\n \r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n\r\n public function getAllProducts() {\r\n try {\r\n $query = \"SELECT * FROM products\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n \r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function getCartItems($userId) {\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function updateCartQuantity($cartId, $quantity) {\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n\r\n public function deleteCartItem($cartId) {\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function deleteAllCartItems($userId) {\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n} ","mutants":[{"id":"d6d54c88f7e7bcc700e5cd534289a119","mutatorName":"DecrementInteger","replacement":"public function getLatestProducts($limit = 5)","description":"Decrements an integer value with 1.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"cb5dee4206891e8397f80d3523a45f24","mutatorName":"IncrementInteger","replacement":"public function getLatestProducts($limit = 7)","description":"Increments an integer value with 1.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"b615375a11c75009f00873c01cc9f5b1","mutatorName":"PublicVisibility","replacement":"protected function getLatestProducts($limit = 6)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nError: Call to protected method Controllers\\ProductController::getLatestProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"ac4b4ea16d5de524f7a4bf1614986fa5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":21,"column":13},"end":{"line":21,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"b0af52ebc8a3f8416a7d37b354590da3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":22,"column":13},"end":{"line":22,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 1, Assertions: 5, Failures: 1.\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"c18f40733296721d67a46880fb59a2ee","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":25,"column":13},"end":{"line":32,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nUndefined array key 0\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:50\n\nERRORS!\r\nTests: 1, Assertions: 1, Errors: 1.\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"e6a75da202b4d89d6bf89556680a9352","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":27,"column":17},"end":{"line":27,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1458 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"f5a1cd95d103243b4c469def77fb7ae3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":28,"column":17},"end":{"line":28,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nFailed asserting that null is identical to 'Producto Test'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:51\n\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1.\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"26097a10bfeb515bb1d953b542b0b8fa","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":29,"column":17},"end":{"line":29,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1454 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"8898976f42919a768ac513dab7a4f6e6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":30,"column":17},"end":{"line":30,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"4d1ac6ed6893512957b4a9153e3cc6ee","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener productos: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"00ccebca1662d6819abe405d8dd9b480","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"8fcaf7ff70998a616d1aecac111045dc","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener productos: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1462 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"ad8cc5770c1b7e73b23769d969d399b5","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1454 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"b4b0e110d7b05163ec40be42238cdb37","mutatorName":"PublicVisibility","replacement":"protected function addToCart($userId, $productData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":40,"column":5},"end":{"line":40,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"f4ec3b9d0c2842861563b5d1e97da9af","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":43,"column":13},"end":{"line":43,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"4138a8579f71e8f7077aa1ca4ac61b94","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":44,"column":13},"end":{"line":44,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"261655f88d0d4a2df1188efb1f6346a8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":45,"column":13},"end":{"line":45,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"d915a71b9d8b30c4e4b3bd7bc9f23e5c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":46,"column":13},"end":{"line":46,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"702272c32699bb6eee6e6d986f324598","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":47,"column":13},"end":{"line":47,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"35cde21cf32f8acf0639e13745ea86d3","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$cart->getName()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"602d7a228dd6751acaf07bc3019f4c07","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"a96b3e0e62d4a49204880299299d405f","mutatorName":"GreaterThan","replacement":"if ($stmt->rowCount() >= 0) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":53,"column":13},"end":{"line":53,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"3e64aaf89dd58733dfc34969de895b62","mutatorName":"GreaterThanNegotiation","replacement":"if ($stmt->rowCount() <= 0) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":53,"column":13},"end":{"line":53,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"a6f90c4316b1b3e8012f4cf3d9e62308","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El producto ya est\u00e1 en el carrito'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":96}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679"],"killedBy":[],"testsCompleted":0},{"id":"47993b7535206b3af3a84b118f825835","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El producto ya est\u00e1 en el carrito'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":96}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679"],"killedBy":[],"testsCompleted":0},{"id":"c0820143b0a2749619aac748e835a8f9","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":62,"column":13},"end":{"line":68,"column":29}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"9b2e52933a01b2b15d7edc2487d28ab9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":62,"column":13},"end":{"line":68,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nExpectation failed for method name is \"execute\" when invoked 2 time(s).\nMethod was expected to be called 2 times, actually called 1 times.\n\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"d6265aca1d58bf8aca33e7a568c47503","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => 'Producto a\u00f1adido al carrito'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\n\nFAILURES!\r\nTests: 2, Assertions: 6, Failures: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"e26136a2464024cee484dea4abe54d61","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Producto a\u00f1adido al carrito'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"c624c6d9e4ebf2d542fb852c9de594e6","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al a\u00f1adir al carrito: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"3006f81bfb344f8dbfc44721a7ea2e6e","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"3a8966d1e26e0ab9ac37d9ee03b4fcb8","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al a\u00f1adir al carrito: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1458 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.062, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"f5fd0ecc24849b48869aef26fbc453b2","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"4688e1d0a80ef2d0f197c178e36fd694","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al a\u00f1adir al carrito'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1456 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\n\nFAILURES!\r\nTests: 15, Assertions: 49, Failures: 1.\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":["21b277a20d75495834b915634005099f"],"testsCompleted":15},{"id":"18f87be6894ef590a645091114401f5f","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al a\u00f1adir al carrito'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............E\nNotice: fwrite(): Write of 1460 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\n\nERRORS!\r\nTests: 15, Assertions: 48, Errors: 1.\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":["21b277a20d75495834b915634005099f"],"testsCompleted":15},{"id":"b857672f3fe1351e5a657ef4a433a8ab","mutatorName":"PublicVisibility","replacement":"protected function getAllProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":77,"column":5},"end":{"line":77,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nError: Call to protected method Controllers\\ProductController::getAllProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:200\n\nERRORS!\r\nTests: 7, Assertions: 22, Errors: 1.\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc","cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"0fb427f2d05aa2c6c9ea852f70e00675","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":81,"column":13},"end":{"line":81,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 7, Assertions: 28, Failures: 1.\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"21073abf213dd6029c9e66371981903a","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":84,"column":13},"end":{"line":91,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nFailed asserting that actual size 0 matches expected size 2.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:202\n\nFAILURES!\r\nTests: 7, Assertions: 23, Failures: 1.\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"784f6a531ab3840f939ccef4f41214c0","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":86,"column":17},"end":{"line":86,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":[],"testsCompleted":0},{"id":"1a85a8dcc3af9c193671670c138895d1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":87,"column":17},"end":{"line":87,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nFailed asserting that null matches expected 'Producto 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:204\n\nFAILURES!\r\nTests: 7, Assertions: 25, Failures: 1.\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"ce565ed8cbc64274189c97a9cda902e7","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":88,"column":17},"end":{"line":88,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":[],"testsCompleted":0},{"id":"46e2cd6f0c9740e8bcdfa4f8cb0e96f1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":89,"column":17},"end":{"line":89,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":[],"testsCompleted":0},{"id":"1e0894de8803af94aca4e3b90de9b785","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener todos los productos: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"710646a2223ead6b9521b321faf8b0e2","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"39a9bbe4f12cceb23d860a23f43a88f1","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener todos los productos: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"94f1c099842e4ed192f2e9301d9164ae","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"694750d813a3bb2865a9d969a146a3e5","mutatorName":"PublicVisibility","replacement":"protected function getCartItems($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":99,"column":5},"end":{"line":99,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\nError: Call to protected method Controllers\\ProductController::getCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:107\n\nERRORS!\r\nTests: 3, Assertions: 9, Errors: 1.\r\n","coveredBy":["5144a3795216d9768bcf2e1b0de52d7c","47942d6a996427c3c1cec9efff6173b2","242f299f525da768f9961477f538fcf7"],"killedBy":["242f299f525da768f9961477f538fcf7"],"testsCompleted":3},{"id":"ce41b6487e187b75a062456dfb751d5a","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":103,"column":13},"end":{"line":103,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\nFailed asserting that two arrays are identical.\n--- Expected\n+++ Actual\n@@ @@\n-Array &0 (\n- 0 => Array &1 (\n- 'id' => 1\n- 'name' => 'Producto Test'\n- 'price' => 99.99\n- 'quantity' => 1\n- 'image' => 'test.jpg'\n- )\n-)\n+Array &0 ()\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:109\n\nFAILURES!\r\nTests: 3, Assertions: 10, Failures: 1.\r\n","coveredBy":["5144a3795216d9768bcf2e1b0de52d7c","242f299f525da768f9961477f538fcf7"],"killedBy":["242f299f525da768f9961477f538fcf7"],"testsCompleted":3},{"id":"b2da999489995b0a16b3ace9301d5cf2","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":103,"column":13},"end":{"line":103,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 3, Assertions: 12, Failures: 1.\r\n","coveredBy":["5144a3795216d9768bcf2e1b0de52d7c","242f299f525da768f9961477f538fcf7"],"killedBy":["242f299f525da768f9961477f538fcf7"],"testsCompleted":3},{"id":"b4b7f29733608f93f0fc4ad249802726","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener items del carrito: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"5e629f922236b75f97ad9632cb4e2fa9","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"e586a8f894dc539830e72082dd891a41","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener items del carrito: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"e86a4649ebe026d7dbb9fe54acba6b0d","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"7182b103c5983d238b111c4ef2e734b0","mutatorName":"PublicVisibility","replacement":"protected function updateCartQuantity($cartId, $quantity)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":111,"column":5},"end":{"line":111,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8","fc8f4ab810696c7119210820c8dcb994"],"killedBy":[],"testsCompleted":0},{"id":"acdcc7e8050848d4586886ade3091abc","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$cartId]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":115,"column":13},"end":{"line":115,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8","fc8f4ab810696c7119210820c8dcb994"],"killedBy":[],"testsCompleted":0},{"id":"91ee67d8640fd87862f0fb6d52f276ad","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":115,"column":13},"end":{"line":115,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8","fc8f4ab810696c7119210820c8dcb994"],"killedBy":[],"testsCompleted":0},{"id":"842df3cf1478df61d8fb3eb42d776391","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Cantidad actualizada!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":116,"column":13},"end":{"line":116,"column":80}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\n\nFAILURES!\r\nTests: 4, Assertions: 13, Failures: 1.\r\n","coveredBy":["fc8f4ab810696c7119210820c8dcb994"],"killedBy":["fc8f4ab810696c7119210820c8dcb994"],"testsCompleted":4},{"id":"6eb4ca894e3a533334bbd3b28df406cc","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Cantidad actualizada!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":116,"column":13},"end":{"line":116,"column":80}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\n\nERRORS!\r\nTests: 4, Assertions: 12, Errors: 1.\r\n","coveredBy":["fc8f4ab810696c7119210820c8dcb994"],"killedBy":["fc8f4ab810696c7119210820c8dcb994"],"testsCompleted":4},{"id":"39da2691214ce313b6ce6fbf4808b546","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al actualizar cantidad: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"b98195cc14bd1c717572b0958ee04293","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"33d6a8b972c4d59c1c2d6da3deb3bf52","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al actualizar cantidad: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"75a7c65d371cbd0a0ed28b79d4e6e896","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"0ed39a73089454b07426fbc76fee8be7","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al actualizar cantidad'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":119,"column":13},"end":{"line":119,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"5275bf8d1f640c54ab401f64ce141b2e","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al actualizar cantidad'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":119,"column":13},"end":{"line":119,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"522197318da3bd61a75e72545ad15c5c","mutatorName":"PublicVisibility","replacement":"protected function deleteCartItem($cartId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":123,"column":5},"end":{"line":123,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8b777577a59cbaa568701bb5fa606fc0","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"0c55f120518f96672e0d003d4c509474","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":127,"column":13},"end":{"line":127,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8b777577a59cbaa568701bb5fa606fc0"],"killedBy":[],"testsCompleted":0},{"id":"7756a071741569b40c01cd7a0576aba1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":127,"column":13},"end":{"line":127,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8b777577a59cbaa568701bb5fa606fc0"],"killedBy":[],"testsCompleted":0},{"id":"02ae467303479c04e63d40a9b9ecd4ef","mutatorName":"TrueValue","replacement":"return false;","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":128,"column":13},"end":{"line":128,"column":25}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 534 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:149\n\nFAILURES!\r\nTests: 5, Assertions: 17, Failures: 1.\r\n","coveredBy":["8b777577a59cbaa568701bb5fa606fc0"],"killedBy":["8b777577a59cbaa568701bb5fa606fc0"],"testsCompleted":5},{"id":"481706adb6e33cbd18f39166c7917cf9","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al eliminar item: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"99ef156ac0ff799d1a413764f986af93","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"f07b7f491354a1f15c993e61ef0df211","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al eliminar item: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"80c004aac72dbabfdbd00ddb00c3b8d9","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"9a0d3ab9b20de76c20ef894ce56669a9","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":131,"column":13},"end":{"line":131,"column":26}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"308fbcfacbf6d4c16bfc0113ed6b28fe","mutatorName":"PublicVisibility","replacement":"protected function deleteAllCartItems($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":135,"column":5},"end":{"line":135,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nError: Call to protected method Controllers\\ProductController::deleteAllCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:166\n\nERRORS!\r\nTests: 6, Assertions: 19, Errors: 1.\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00","533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"6e114c4ab7e2f414afa7e52bdfd422cb","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":139,"column":13},"end":{"line":139,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\n\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1.\r\n","coveredBy":["533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"5aae6d73a37c216cab4db08ce7ad3ac6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":139,"column":13},"end":{"line":139,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 631 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 6, Assertions: 22, Failures: 1.\r\n","coveredBy":["533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"342ed970ca1ab0f9eb5602796b648c9b","mutatorName":"TrueValue","replacement":"return false;","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":140,"column":13},"end":{"line":140,"column":25}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 631 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\n\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1.\r\n","coveredBy":["533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"e148a239925d471433a1421bb3d3e911","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al eliminar todos los items: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"625eccb5c274d1687527f10a1551b2fa","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1434 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"f2f7c7113613af5584a6953b8d3fca31","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al eliminar todos los items: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1438 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"a8ead461abb707e1c82c5b4631444787","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"39f59d6ad0595696c17a38602edc6600","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":143,"column":13},"end":{"line":143,"column":26}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1386 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:317\n\nFAILURES!\r\nTests: 14, Assertions: 47, Failures: 1.\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":["9079b2b01975467bd588ac0635613e00"],"testsCompleted":14}]},"Controllers\/SearchController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function searchProducts($searchTerm) {\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";\r\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\r\n $stmt->execute([$searchTerm]);\r\n \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n} ","mutants":[{"id":"1b53660b7664fdc49d4ff09f09eef290","mutatorName":"PublicVisibility","replacement":"protected function searchProducts($searchTerm)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":11,"column":5},"end":{"line":11,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 217 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.102, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados\nError: Call to protected method Controllers\\SearchController::searchProducts() from scope Tests\\Unit\\Controllers\\SearchControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:38\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["119dcc727a6c5c37089ce369397e3936","38f507e5499b7d283bd2d73a0e5dab72","9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["38f507e5499b7d283bd2d73a0e5dab72"],"testsCompleted":1},{"id":"928a3b37b4a528c89295bc4f76e56157","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":15,"column":13},"end":{"line":15,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nParameter 0 for invocation PDOStatement::execute(Array ()): bool does not match expected value.\nFailed asserting that two arrays are equal.\n--- Expected\n+++ Actual\n@@ @@\n Array (\n- 0 => '%%'\n )\n\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1.\r\n","coveredBy":["119dcc727a6c5c37089ce369397e3936","38f507e5499b7d283bd2d73a0e5dab72"],"killedBy":["08bac488cb269f384def5af24b61d002"],"testsCompleted":4},{"id":"e06dd7f9ae3c6dc0ab29eec89bf75650","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":15,"column":13},"end":{"line":15,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1.\r\n","coveredBy":["119dcc727a6c5c37089ce369397e3936","38f507e5499b7d283bd2d73a0e5dab72"],"killedBy":["08bac488cb269f384def5af24b61d002"],"testsCompleted":4},{"id":"79fa78ac3915f90a1f841a68248280dc","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en b\u00fasqueda: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '[11-Dec-2024 17:31:12 Europe\/Berlin] Error de pruebaError en b\u00fasqueda: \\r\\n\n' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5},{"id":"3568f49bca400f1501d0c67eb800a0d8","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '[11-Dec-2024 17:31:13 Europe\/Berlin] Error de prueba\\r\\n\n' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5},{"id":"577e5d590dc49afd50853644d046927d","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en b\u00fasqueda: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '[11-Dec-2024 17:31:13 Europe\/Berlin] Error en b\u00fasqueda: \\r\\n\n' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5},{"id":"874cb741ca2c3b125473262c4d449fd0","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 651 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5}]},"Controllers\/UserController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n private function hashPassword($password) {\r\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n }\r\n\r\n private function verifyPassword($password, $hashedPassword) {\r\n return password_verify($password, $hashedPassword);\r\n }\r\n\r\n public function registerUser($userData) {\r\n try {\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n $user->setEmail($userData['email']);\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);\r\n if($stmt->fetch()) {\r\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }\r\n\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\r\n \"INSERT INTO users (name, email, password, user_type) \r\n VALUES (?, ?, ?, ?)\"\r\n );\r\n \r\n $stmt->execute([\r\n $user->getName(),\r\n $user->getEmail(),\r\n $this->hashPassword($userData['password']),\r\n $user->getUserType()\r\n ]);\r\n \r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }\r\n\r\n public function loginUser($email, $password) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n $stmt->execute([$email]);\r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n\r\n if ($user && $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];\r\n $_SESSION['user_email'] = $user['email'];\r\n return ['success' => true, 'user_type' => $user['user_type']];\r\n }\r\n\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }\r\n\r\n public function logout() {\r\n try {\r\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\r\n if (session_status() === PHP_SESSION_NONE) {\r\n session_start();\r\n }\r\n \r\n \/\/ Limpiar todas las variables de sesi\u00f3n\r\n $_SESSION = array();\r\n \r\n \/\/ Destruir la sesi\u00f3n\r\n session_destroy();\r\n \r\n \/\/ Redireccionar al login\r\n header('location: ..\/auth\/login.php');\r\n exit();\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en logout: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\r\n }\r\n }\r\n\r\n public function getUserById($userId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n return null;\r\n }\r\n }\r\n\r\n \/\/ Alias para mantener compatibilidad\r\n public function register($userData) {\r\n return $this->registerUser($userData);\r\n }\r\n} ","mutants":[{"id":"5c7d14398573f28a8168a9e3aa94f1d6","mutatorName":"ArrayItemRemoval","replacement":"return password_hash($password, PASSWORD_BCRYPT, []);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":15,"column":9},"end":{"line":15,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 1132 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.532, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\nFailed asserting that '$2y$10$XDgAfdc4CNZQgmDaK1V58OdWUiq2Rd4AE28Mj1sYl3KQMMfGnTQ7.' contains \"$2y$12$\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:233\n\nFAILURES!\r\nTests: 12, Assertions: 23, Failures: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","c5f619a697779b293907d101b23e2cc5","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["c5f619a697779b293907d101b23e2cc5"],"testsCompleted":12},{"id":"738b4ea5c36a7e50d82122b39a6328e8","mutatorName":"FunctionCall","replacement":"password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n return null;","description":"Replaces a returned evaluated function with `null` instead. The function evaluation statement is kept\nin order to preserve potential side effects. For example:\n\n```php\nclass X {\n function foo()\n {\n return bar();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo()\n {\n bar();\n return null;\n }\n}\n```\n","location":{"start":{"line":15,"column":9},"end":{"line":15,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 1132 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:01.332, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:232\n\nFAILURES!\r\nTests: 12, Assertions: 22, Failures: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","c5f619a697779b293907d101b23e2cc5","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["c5f619a697779b293907d101b23e2cc5"],"testsCompleted":12},{"id":"0719ff7f8976df5f9520fe675d12f6a9","mutatorName":"FunctionCall","replacement":"password_verify($password, $hashedPassword);\r\n return null;","description":"Replaces a returned evaluated function with `null` instead. The function evaluation statement is kept\nin order to preserve potential side effects. For example:\n\n```php\nclass X {\n function foo()\n {\n return bar();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo()\n {\n bar();\n return null;\n }\n}\n```\n","location":{"start":{"line":19,"column":9},"end":{"line":19,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.371, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:62\n\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","e90d3c5d6475a8b9876cd1a2fd342fc2","c0b609be3f46cabd11f9479c3867ba10","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","bc66590a599c81f251afe7f022704124","7a41cc8095f8763e256eeeabc2964148"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"8dde8a9053d96b8733621c7d6f84f757","mutatorName":"PublicVisibility","replacement":"protected function registerUser($userData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\nError: Call to protected method Controllers\\UserController::registerUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:31\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["4e5d456bcd3f0f480afe371d6ab58a3a"],"testsCompleted":1},{"id":"88ac82b58817201202f1520e653d9549","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":25,"column":13},"end":{"line":25,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.602, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"343af5360ff837a558ed686daa26c48f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":26,"column":13},"end":{"line":26,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2926 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.635, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"a40cd7fc558936e3df77cfc7dce03a81","mutatorName":"Coalesce","replacement":"$user->setUserType('user' ?? $userData['user_type']);","description":"Swaps the coalesce operator (`??`) operands,\ne.g. replaces `$a ?? $b` with `$b ?? $a` or `$a ?? $b ?? $c` with `$b ?? $a ?? $c` and `$a ?? $c ?? $b`.","location":{"start":{"line":27,"column":13},"end":{"line":27,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2916 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.595, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"280066033e5ce7f7f3be0f84088f8eb9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":27,"column":13},"end":{"line":27,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.531, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"3dbd4a9ae6e29b786f505758b48734bf","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":31,"column":13},"end":{"line":31,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.670, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"caea43ad25065db4011a9d2e17221460","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":31,"column":13},"end":{"line":31,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2917 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:04.035, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"5e7c850525b5c190daf92173cd4974b9","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El correo ya est\u00e1 registrado'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":33,"column":17},"end":{"line":33,"column":91}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 550 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.342, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 10, Failures: 1.\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","5562fefd1e6267f1330a8be9c24c0c1e"],"killedBy":["cf7f861e585d3046cc970897756c7229"],"testsCompleted":5},{"id":"beb970f03de23216fc17a6f76c7bab2d","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El correo ya est\u00e1 registrado'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":33,"column":17},"end":{"line":33,"column":91}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 550 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.373, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:117\n\nERRORS!\r\nTests: 5, Assertions: 9, Errors: 1.\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","5562fefd1e6267f1330a8be9c24c0c1e"],"killedBy":["cf7f861e585d3046cc970897756c7229"],"testsCompleted":5},{"id":"24ab589e57076ff1f172e8f8484814a7","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":42,"column":13},"end":{"line":47,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................E 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2984 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:01.448, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\nUndefined array key 3\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:649\n\nERRORS!\r\nTests: 34, Assertions: 62, Errors: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["82b33ea8be7f215b2cef162114a6d5c3"],"testsCompleted":34},{"id":"21f2d16ca4933351ea8de87f9521b85c","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":42,"column":13},"end":{"line":47,"column":29}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................E 34 \/ 34 (100%)\nNotice: fwrite(): Write of 3008 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.598, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\nUndefined array key 3\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:649\n\nERRORS!\r\nTests: 34, Assertions: 62, Errors: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["82b33ea8be7f215b2cef162114a6d5c3"],"testsCompleted":34},{"id":"afe810cfe705a043850a1e9ea546a079","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => 'Registro exitoso!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":49,"column":13},"end":{"line":49,"column":74}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.244, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:37\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["4e5d456bcd3f0f480afe371d6ab58a3a"],"testsCompleted":1},{"id":"84bc447e93f0196e863626eb6355258d","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Registro exitoso!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":49,"column":13},"end":{"line":49,"column":74}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.237, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:37\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["4e5d456bcd3f0f480afe371d6ab58a3a"],"testsCompleted":1},{"id":"9beadead9da3a13eaa9a5859ce0e8562","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en registro: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2912 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.399, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"10d8096bc7e3f58cab36bc627f7f70a8","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2910 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.394, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"476be47e67cce512fcd1b0dccff5f720","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en registro: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2920 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.430, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"f1a4e74b3a2448645f1c25ddbfc747ea","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2905 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.415, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"45670895b720aa18fe43b100e7d3712f","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error en el registro'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":52,"column":13},"end":{"line":52,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.354, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:135\n\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1.\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["1884bc4f1d1fef63116444d66c172e6b"],"testsCompleted":6},{"id":"7449317dbffa6f21bff28584d2724102","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error en el registro'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":52,"column":13},"end":{"line":52,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.361, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:135\n\nERRORS!\r\nTests: 6, Assertions: 11, Errors: 1.\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["1884bc4f1d1fef63116444d66c172e6b"],"testsCompleted":6},{"id":"16763f03a1d5d0d0c6f0278176776ba6","mutatorName":"PublicVisibility","replacement":"protected function loginUser($email, $password)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":56,"column":5},"end":{"line":56,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.333, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nError: Call to protected method Controllers\\UserController::loginUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:60\n\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"17fe93b273d2985ac03367be5f5b4d51","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 684 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.351, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Error en el inicio de sesi\u00f3n'\n+'Correo o contrase\u00f1a incorrectos'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:150\n\nFAILURES!\r\nTests: 7, Assertions: 15, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["dc1973acbaca0a28a598effc18237ad0"],"testsCompleted":7},{"id":"30721036ae14caed212b1591eb511824","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........................F\nNotice: fwrite(): Write of 2462 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.476, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_parametros_vacios\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Error en el inicio de sesi\u00f3n'\n+'Correo o contrase\u00f1a incorrectos'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:503\n\nFAILURES!\r\nTests: 28, Assertions: 48, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["8f6806446dc730bfa17ccb11eb2d00c1"],"testsCompleted":28},{"id":"16d0632e9cd3710147f6dde9fac3f1f0","mutatorName":"LogicalAnd","replacement":"if ($user || $this->verifyPassword($password, $user['password'])) {","description":"Replaces an AND operator (`&&`) with an OR operator (`||`).","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":80}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.291, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\nFailed asserting that two strings are identical.\n--- Expected\n+++ Actual\n@@ @@\n-'Correo o contrase\u00f1a incorrectos'\n+'Error en el inicio de sesi\u00f3n'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:78\n\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["377db5af9ac5ffe374c7f038544ba613"],"testsCompleted":3},{"id":"d16518173c8347fb3a86ac316825b0d4","mutatorName":"TrueValue","replacement":"return ['success' => false, 'user_type' => $user['user_type']];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":67,"column":17},"end":{"line":67,"column":79}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:62\n\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1.\r\n","coveredBy":["2c9e012a8ef82162dc733a7d5ed147cb","bc66590a599c81f251afe7f022704124"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"bc98c8772c8965bc069b76d217563515","mutatorName":"ArrayItemRemoval","replacement":"return ['user_type' => $user['user_type']];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":67,"column":17},"end":{"line":67,"column":79}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.338, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:62\n\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1.\r\n","coveredBy":["2c9e012a8ef82162dc733a7d5ed147cb","bc66590a599c81f251afe7f022704124"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"bce68386ab606a2349c0a3b542568e23","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Correo o contrase\u00f1a incorrectos'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":90}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.338, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:77\n\nFAILURES!\r\nTests: 3, Assertions: 5, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","f68eb8b986d9fc309ed29c287efd52cb","377db5af9ac5ffe374c7f038544ba613","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["377db5af9ac5ffe374c7f038544ba613"],"testsCompleted":3},{"id":"da7a171e99dd467cded6998ad76deb1a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Correo o contrase\u00f1a incorrectos'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":90}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.349, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:77\n\nERRORS!\r\nTests: 3, Assertions: 4, Errors: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","f68eb8b986d9fc309ed29c287efd52cb","377db5af9ac5ffe374c7f038544ba613","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["377db5af9ac5ffe374c7f038544ba613"],"testsCompleted":3},{"id":"b4199a70eef327c50b833f9c5555f0b7","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en login: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2922 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.622, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"b76d5b9100e95dd8aa6fa3aa20c248a9","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2940 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.659, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"e209385317906488e93b10a361a2f412","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en login: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2908 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.637, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"88dc5b029aa89f1a4af55357887df49a","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2923 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.675, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"d93c581d9b9142b82bab2b94b70d1887","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error en el inicio de sesi\u00f3n'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 688 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.386, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:149\n\nFAILURES!\r\nTests: 7, Assertions: 14, Failures: 1.\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":["dc1973acbaca0a28a598effc18237ad0"],"testsCompleted":7},{"id":"5ea83094147bb1955d2f7571d37a1da5","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error en el inicio de sesi\u00f3n'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 692 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.404, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:149\n\nERRORS!\r\nTests: 7, Assertions: 13, Errors: 1.\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":["dc1973acbaca0a28a598effc18237ad0"],"testsCompleted":7},{"id":"d6f06b8d343436d0d566a506e366801b","mutatorName":"PublicVisibility","replacement":"protected function getUserById($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":99,"column":5},"end":{"line":99,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 459 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.343, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id\nError: Call to protected method Controllers\\UserController::getUserById() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:95\n\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1.\r\n","coveredBy":["a3214e814150e4694e5bde76166b4a2b","6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d","ebc491f7be9fdad3965e5ccdf30566c6","62b48a5e15de8d584745b990f5316ddb"],"killedBy":["ebc491f7be9fdad3965e5ccdf30566c6"],"testsCompleted":4},{"id":"f651a6456dc6265a0a8454dedc4d49a3","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":102,"column":13},"end":{"line":102,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............................F\nNotice: fwrite(): Write of 2715 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.576, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_id_nulo\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nParameter 0 for invocation PDOStatement::execute(Array ()): bool does not match expected value.\nFailed asserting that two arrays are equal.\n--- Expected\n+++ Actual\n@@ @@\n Array (\n- 0 => null\n )\n\nFAILURES!\r\nTests: 31, Assertions: 54, Failures: 1.\r\n","coveredBy":["a3214e814150e4694e5bde76166b4a2b","6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d","ebc491f7be9fdad3965e5ccdf30566c6","62b48a5e15de8d584745b990f5316ddb"],"killedBy":["237855d7625b09db7d9986028a0829fe"],"testsCompleted":31},{"id":"dd29834c47f796a3e2c0c5b2b4d937d1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":102,"column":13},"end":{"line":102,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............................F\nNotice: fwrite(): Write of 2714 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.540, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_id_nulo\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 31, Assertions: 54, Failures: 1.\r\n","coveredBy":["a3214e814150e4694e5bde76166b4a2b","6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d","ebc491f7be9fdad3965e5ccdf30566c6","62b48a5e15de8d584745b990f5316ddb"],"killedBy":["237855d7625b09db7d9986028a0829fe"],"testsCompleted":31},{"id":"4f9430b4ee2794c1a4821376bbbcd075","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener usuario: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2920 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.757, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"bb9ba792029d68b0a4daeffca9257b24","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2922 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.736, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"098b40e57246dffceb49edff37d66d1d","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener usuario: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2917 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.689, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"17b7f1db4eb950d4976c0376e3ae1af4","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................. 34 \/ 34 (100%)\nNotice: fwrite(): Write of 2912 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.681, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"7fbec6fd2ce178710277d50b17eea149","mutatorName":"PublicVisibility","replacement":"protected function register($userData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":111,"column":5},"end":{"line":111,"column":42}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 949 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.584, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register\nError: Call to protected method Controllers\\UserController::register() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:195\n\nERRORS!\r\nTests: 10, Assertions: 18, Errors: 1.\r\n","coveredBy":["5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["5f1ac69ed727a6a2093d161091ef2238"],"testsCompleted":10}]},"Exceptions\/DatabaseException.php":{"language":"php","source":"id; }\r\n public function getUserId() { return $this->userId; }\r\n public function getName() { return $this->name; }\r\n public function getPrice() { return $this->price; }\r\n public function getQuantity() { return $this->quantity; }\r\n public function getImage() { return $this->image; }\r\n\r\n \/\/ Setters\r\n public function setUserId($userId) { $this->userId = $userId; }\r\n public function setName($name) { $this->name = $name; }\r\n public function setPrice($price) { $this->price = $price; }\r\n public function setQuantity($quantity) { $this->quantity = $quantity; }\r\n public function setImage($image) { $this->image = $image; }\r\n} ","mutants":[{"id":"a2131e7a148aa9494015c5c650c8c832","mutatorName":"PublicVisibility","replacement":"protected function getUserId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":14,"column":5},"end":{"line":14,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getUserId() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:63\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"9c1fadc9e55e723829a99d4e07ba25be","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":15,"column":5},"end":{"line":15,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"92ad38d69dbb0a57e52ca518c9f0fc57","mutatorName":"PublicVisibility","replacement":"protected function getPrice()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":16,"column":5},"end":{"line":16,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getPrice() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:65\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"b5069b312fefd6cee2b6bcc06042962c","mutatorName":"PublicVisibility","replacement":"protected function getQuantity()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 267 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getQuantity() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:66\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"f85ecb8bee4c3007da6bc019811aa092","mutatorName":"PublicVisibility","replacement":"protected function getImage()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getImage() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:67\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"57ca1ca2f090527721ac6221bc0276d8","mutatorName":"PublicVisibility","replacement":"protected function setUserId($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"913393895f84efe9a7161fe0256b4aa6","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"8e481315494a5baccbce668972d6ab2b","mutatorName":"PublicVisibility","replacement":"protected function setPrice($price)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"b61530515ee44861833da34dc5b15609","mutatorName":"PublicVisibility","replacement":"protected function setQuantity($quantity)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"413f4b0a8ac2fc3f6336947c539b5157","mutatorName":"PublicVisibility","replacement":"protected function setImage($image)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":25,"column":5},"end":{"line":25,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0}]},"Models\/Message.php":{"language":"php","source":"id; }\r\n public function getUserId() { return $this->userId; }\r\n public function getName() { return $this->name; }\r\n public function getEmail() { return $this->email; }\r\n public function getNumber() { return $this->number; }\r\n public function getMessage() { return $this->message; }\r\n\r\n \/\/ Setters\r\n public function setUserId($userId) { $this->userId = $userId; }\r\n public function setName($name) { $this->name = $name; }\r\n public function setEmail($email) { $this->email = $email; }\r\n public function setNumber($number) { $this->number = $number; }\r\n public function setMessage($message) { $this->message = $message; }\r\n\r\n public function exists($conn) {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);\r\n $stmt->execute([$this->userId, $this->message]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n\r\n public function save($conn) {\r\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $conn->prepare($sql);\r\n return $stmt->execute([\r\n $this->userId,\r\n $this->name,\r\n $this->email,\r\n $this->number,\r\n $this->message\r\n ]);\r\n }\r\n\r\n public function setId($id) { $this->id = $id; }\r\n} ","mutants":[{"id":"228f125cdebcdeadcd41e08c8ed9d512","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":13,"column":5},"end":{"line":13,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\nError: Call to protected method Models\\Message::getId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:28\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["526a8af9ac30be501c7f4b37124d576f"],"killedBy":["526a8af9ac30be501c7f4b37124d576f"],"testsCompleted":1},{"id":"777979e737c9911d705760828ab4d590","mutatorName":"PublicVisibility","replacement":"protected function getUserId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":14,"column":5},"end":{"line":14,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\nError: Call to protected method Models\\Message::getUserId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:36\n\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1.\r\n","coveredBy":["982c4d44a4015074431dc655f61bf9c9"],"killedBy":["982c4d44a4015074431dc655f61bf9c9"],"testsCompleted":2},{"id":"d81474f147a42513673c33ed1912c99f","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":15,"column":5},"end":{"line":15,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\nError: Call to protected method Models\\Message::getName() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:44\n\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1.\r\n","coveredBy":["2b1642fa5d7b37210b33ee2a94697390"],"killedBy":["2b1642fa5d7b37210b33ee2a94697390"],"testsCompleted":3},{"id":"a024a981caafb460e3f2edf7766f19b0","mutatorName":"PublicVisibility","replacement":"protected function getEmail()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":16,"column":5},"end":{"line":16,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\nError: Call to protected method Models\\Message::getEmail() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:52\n\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","19542864ba4ef81044cd17038a6e8c59"],"killedBy":["19542864ba4ef81044cd17038a6e8c59"],"testsCompleted":4},{"id":"2d27e77e56ca53d21c0bc139aef41d46","mutatorName":"PublicVisibility","replacement":"protected function getNumber()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\nError: Call to protected method Models\\Message::getNumber() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:60\n\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1.\r\n","coveredBy":["acf82b784e1fde7256a6c27e70355a65"],"killedBy":["acf82b784e1fde7256a6c27e70355a65"],"testsCompleted":5},{"id":"b8773819023d633a3575d28eaeeefec2","mutatorName":"PublicVisibility","replacement":"protected function getMessage()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\nError: Call to protected method Models\\Message::getMessage() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:68\n\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","83c78b91f60c0ee0e7c5af4cda4ca08c"],"killedBy":["83c78b91f60c0ee0e7c5af4cda4ca08c"],"testsCompleted":6},{"id":"e02eff8937e71705a2a2021358f67769","mutatorName":"PublicVisibility","replacement":"protected function setUserId($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\nError: Call to protected method Models\\Message::setUserId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:35\n\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","09cbcccec0a12bf6ed83725861831d3b","9fac10250403152dbfd443e6d82c8728","982c4d44a4015074431dc655f61bf9c9"],"killedBy":["982c4d44a4015074431dc655f61bf9c9"],"testsCompleted":2},{"id":"baa9f0594b32fba290f03ef75dbee02f","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\nError: Call to protected method Models\\Message::setName() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:43\n\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728","2b1642fa5d7b37210b33ee2a94697390"],"killedBy":["2b1642fa5d7b37210b33ee2a94697390"],"testsCompleted":3},{"id":"2fc545178dae19a6ebf5437259901f43","mutatorName":"PublicVisibility","replacement":"protected function setEmail($email)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\nError: Call to protected method Models\\Message::setEmail() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:51\n\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728","19542864ba4ef81044cd17038a6e8c59"],"killedBy":["19542864ba4ef81044cd17038a6e8c59"],"testsCompleted":4},{"id":"48709a983e17cafabbcf9de84d625457","mutatorName":"PublicVisibility","replacement":"protected function setNumber($number)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\nError: Call to protected method Models\\Message::setNumber() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:59\n\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728","acf82b784e1fde7256a6c27e70355a65"],"killedBy":["acf82b784e1fde7256a6c27e70355a65"],"testsCompleted":5},{"id":"f9050a2c4accf576a1277882ac7b2bc7","mutatorName":"PublicVisibility","replacement":"protected function setMessage($message)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":25,"column":5},"end":{"line":25,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 542 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\nError: Call to protected method Models\\Message::setMessage() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:67\n\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","09cbcccec0a12bf6ed83725861831d3b","9fac10250403152dbfd443e6d82c8728","83c78b91f60c0ee0e7c5af4cda4ca08c"],"killedBy":["83c78b91f60c0ee0e7c5af4cda4ca08c"],"testsCompleted":6},{"id":"d6b5994a2b17f64161a9fa6ad42b09da","mutatorName":"PublicVisibility","replacement":"protected function exists($conn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":27,"column":5},"end":{"line":27,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E 9 \/ 9 (100%)\nNotice: fwrite(): Write of 750 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\nError: Call to protected method Models\\Message::exists() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:128\n\nERRORS!\r\nTests: 9, Assertions: 12, Errors: 1.\r\n","coveredBy":["09cbcccec0a12bf6ed83725861831d3b"],"killedBy":["09cbcccec0a12bf6ed83725861831d3b"],"testsCompleted":9},{"id":"c4ca60b925843ac6ecec8f2d99fc1c51","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$this->message]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":30,"column":9},"end":{"line":30,"column":57}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......... 9 \/ 9 (100%)\nNotice: fwrite(): Write of 675 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)\r\n","coveredBy":["09cbcccec0a12bf6ed83725861831d3b"],"killedBy":[],"testsCompleted":0},{"id":"8569ef4543891a57003e45e35bce4534","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":30,"column":9},"end":{"line":30,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F 9 \/ 9 (100%)\nNotice: fwrite(): Write of 750 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["09cbcccec0a12bf6ed83725861831d3b"],"killedBy":["09cbcccec0a12bf6ed83725861831d3b"],"testsCompleted":9},{"id":"de4e6ffdab2fe70be2072b7dd08d82cf","mutatorName":"PublicVisibility","replacement":"protected function save($conn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":34,"column":5},"end":{"line":34,"column":34}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 590 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje\nError: Call to protected method Models\\Message::save() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:88\n\nERRORS!\r\nTests: 7, Assertions: 6, Errors: 1.\r\n","coveredBy":["4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728"],"killedBy":["4813abd1aac2f55ae34e6218d3266a72"],"testsCompleted":7},{"id":"24e24d7f7d71d379da4846228c647b01","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([$this->name, $this->email, $this->number, $this->message]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":37,"column":9},"end":{"line":43,"column":32}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......... 9 \/ 9 (100%)\nNotice: fwrite(): Write of 676 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)\r\n","coveredBy":["4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728"],"killedBy":[],"testsCompleted":0},{"id":"2310043b6b321e22f9472a24dd1adfe8","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":46,"column":5},"end":{"line":46,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\nError: Call to protected method Models\\Message::setId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:27\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","526a8af9ac30be501c7f4b37124d576f"],"killedBy":["526a8af9ac30be501c7f4b37124d576f"],"testsCompleted":1}]},"Models\/Order.php":{"language":"php","source":"id; }\r\n public function getUserId() { return $this->userId; }\r\n public function getName() { return $this->name; }\r\n public function getNumber() { return $this->number; }\r\n public function getEmail() { return $this->email; }\r\n public function getMethod() { return $this->method; }\r\n public function getAddress() { return $this->address; }\r\n public function getTotalProducts() { return $this->totalProducts; }\r\n public function getTotalPrice() { return $this->totalPrice; }\r\n public function getPlacedOn() { return $this->placedOn; }\r\n public function getPaymentStatus() { return $this->paymentStatus; }\r\n\r\n \/\/ Setters\r\n public function setUserId($userId) { $this->userId = $userId; }\r\n public function setName($name) { $this->name = $name; }\r\n public function setNumber($number) { $this->number = $number; }\r\n public function setEmail($email) { $this->email = $email; }\r\n public function setMethod($method) { $this->method = $method; }\r\n public function setAddress($address) { $this->address = $address; }\r\n public function setTotalProducts($totalProducts) { $this->totalProducts = $totalProducts; }\r\n public function setTotalPrice($totalPrice) { $this->totalPrice = $totalPrice; }\r\n public function setPaymentStatus($status) { $this->paymentStatus = $status; }\r\n public function setPlacedOn($placedOn) { $this->placedOn = $placedOn; }\r\n\r\n public function setId($id) {\r\n $this->id = $id;\r\n return $this;\r\n }\r\n} ","mutants":[{"id":"63bd49d5fc302bdfedbd85612b31a494","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\nError: Call to protected method Models\\Order::getId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:322\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\n\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1.\r\n","coveredBy":["9f4d645aba7ebec46f8fa49817ad0027","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["9cf07fc703009bc41d2d6794677c2465"],"testsCompleted":3},{"id":"913fb692e2e9c37e3f35d0989f5d5e9b","mutatorName":"PublicVisibility","replacement":"protected function getUserId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":19,"column":5},"end":{"line":19,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getUserId() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:151\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"74a45caf698ef5b2efb8d437a218317c","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":20,"column":5},"end":{"line":20,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getName() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:131\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"c8d2aff30a1dde8c3a01643a14c26dfa","mutatorName":"PublicVisibility","replacement":"protected function getNumber()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getNumber() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:132\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"8823c16d271997b09b59873492a14c07","mutatorName":"PublicVisibility","replacement":"protected function getEmail()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getEmail() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:133\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"613b926c9561f32afd3261ed1ac3b595","mutatorName":"PublicVisibility","replacement":"protected function getMethod()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getMethod() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:134\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"633c102c14dbaef64a9658d4c00255d4","mutatorName":"PublicVisibility","replacement":"protected function getAddress()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getAddress() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:135\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"cb5ee3637f3d77e6b7da593feae5a846","mutatorName":"PublicVisibility","replacement":"protected function getTotalProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":25,"column":5},"end":{"line":25,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getTotalProducts() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:136\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"32d627f962cd6c9c73e7d20460b7724b","mutatorName":"PublicVisibility","replacement":"protected function getTotalPrice()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":26,"column":5},"end":{"line":26,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getTotalPrice() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:137\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"f82d6a7b6041cb2a0b6f90e9ed6afe11","mutatorName":"PublicVisibility","replacement":"protected function getPaymentStatus()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":28,"column":5},"end":{"line":28,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\nError: Call to protected method Models\\Order::getPaymentStatus() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:322\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\n\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1.\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["9cf07fc703009bc41d2d6794677c2465"],"testsCompleted":3},{"id":"88a868717280e767ad64dea879ba6117","mutatorName":"PublicVisibility","replacement":"protected function setUserId($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":31,"column":5},"end":{"line":31,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"337aa315c12a084474a3aa5ad69e27ca","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":32,"column":5},"end":{"line":32,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"5bfa69ce65ca15763c6ced4109e6c2f3","mutatorName":"PublicVisibility","replacement":"protected function setNumber($number)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":33,"column":5},"end":{"line":33,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"75d6cedf938fe8ca8e982173122b4e86","mutatorName":"PublicVisibility","replacement":"protected function setEmail($email)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":34,"column":5},"end":{"line":34,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"dbc80e732884d163270102613d749cab","mutatorName":"PublicVisibility","replacement":"protected function setMethod($method)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":35,"column":5},"end":{"line":35,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"252b9a67b5cb559217d0d5577c11a918","mutatorName":"PublicVisibility","replacement":"protected function setAddress($address)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":36,"column":5},"end":{"line":36,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::setAddress() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:120\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"0c21729cc9c830e0ab24f769c0d90853","mutatorName":"PublicVisibility","replacement":"protected function setTotalProducts($totalProducts)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":37,"column":5},"end":{"line":37,"column":96}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::setTotalProducts() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:121\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"99f3abc32b985609efecb48292c73cf4","mutatorName":"PublicVisibility","replacement":"protected function setTotalPrice($totalPrice)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":38,"column":5},"end":{"line":38,"column":84}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 166 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::setTotalPrice() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:122\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"41a3c57b52e9caddf159efd3c2eb26c6","mutatorName":"PublicVisibility","replacement":"protected function setPaymentStatus($status)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":39,"column":5},"end":{"line":39,"column":82}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nError: Call to protected method Models\\Order::setPaymentStatus() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:198\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\n\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465","27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"663a397afac6aadf72dec6e2e068a38e","mutatorName":"PublicVisibility","replacement":"protected function setPlacedOn($placedOn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":40,"column":5},"end":{"line":40,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nError: Call to protected method Models\\Order::setPlacedOn() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:199\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\n\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"bd4f31186e3e1d7b3d7f755959e14ed6","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":42,"column":5},"end":{"line":42,"column":33}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\nError: Call to protected method Models\\Order::setId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:42\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:24\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","9f4d645aba7ebec46f8fa49817ad0027","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["0035c38ba38c88bdf071f30dece5b1ed"],"testsCompleted":1},{"id":"bed87732fba8c6591787acf1d621e117","mutatorName":"This","replacement":"return null;","description":"Replaces a `return $this` statement with `return null` instead.","location":{"start":{"line":44,"column":9},"end":{"line":44,"column":22}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............................. 30 \/ 30 (100%)\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","9f4d645aba7ebec46f8fa49817ad0027","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":[],"testsCompleted":0}]},"Models\/Product.php":{"language":"php","source":"id; }\r\n public function getName() { return $this->name; }\r\n public function getPrice() { return $this->price; }\r\n public function getImage() { return $this->image; }\r\n\r\n \/\/ Setters\r\n public function setName($name) { $this->name = $name; }\r\n public function setPrice($price) { $this->price = $price; }\r\n public function setImage($image) { $this->image = $image; }\r\n\r\n public function setId($id) {\r\n $this->id = $id;\r\n }\r\n}","mutants":[{"id":"e8a4e47d6ac3c391ddc28a7e5f3d420b","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":11,"column":5},"end":{"line":11,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW..........E\nNotice: fwrite(): Write of 926 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nError: Call to protected method Models\\Product::getId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:262\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 12, Assertions: 27, Errors: 1, Warnings: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"1a41ff3508b6d56a935400230a65dab3","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":12,"column":5},"end":{"line":12,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:251\n\nERRORS!\r\nTests: 8, Assertions: 28, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"0ea3d926f52fae86a8c10c3d8e702f3b","mutatorName":"PublicVisibility","replacement":"protected function getPrice()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":13,"column":5},"end":{"line":13,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.E\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nError: Call to protected method Models\\Product::getPrice() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:129\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","cf7867dae1c09fe7077fa87406af264c","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"e53583027ac717d68c3665a3b447be0e","mutatorName":"PublicVisibility","replacement":"protected function getImage()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":14,"column":5},"end":{"line":14,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nW.E\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nError: Call to protected method Models\\Product::getImage() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:129\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\n\n--\n\nThere was 1 warning:\n\n1) Warning\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\n\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"3ab9a0ff89faa485bc56ec608e903fad","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::setName() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:215\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\n\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"6765638887b4fda56864d5af924860a0","mutatorName":"PublicVisibility","replacement":"protected function setPrice($price)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::setPrice() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:216\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\n\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"e3a188ba795e18b32ab9896ff76aff90","mutatorName":"PublicVisibility","replacement":"protected function setImage($image)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":19,"column":5},"end":{"line":19,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::setImage() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:217\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\n\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":8},{"id":"cca9af17ca1be50e4bb68876371bae35","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":33}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 200 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nError: Call to protected method Models\\Product::setId() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:27\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","cf7867dae1c09fe7077fa87406af264c","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1}]},"Models\/User.php":{"language":"php","source":"userType = 'user';\r\n }\r\n\r\n \/\/ Getters\r\n public function getId() { return $this->id; }\r\n public function getName() { return $this->name; }\r\n public function getEmail() { return $this->email; }\r\n public function getUserType() { return $this->userType; }\r\n\r\n \/\/ Setters\r\n public function setName($name) { $this->name = $name; }\r\n public function setEmail($email) { $this->email = $email; }\r\n public function setPassword($password) { \r\n $this->password = password_hash($password, PASSWORD_DEFAULT);\r\n }\r\n public function setUserType($userType) { $this->userType = $userType; }\r\n public function setId($id) { \r\n $this->id = $id; \r\n return $this;\r\n }\r\n\r\n public function exists($conn) {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n}","mutants":[{"id":"a812385f0e460e1912e529ecaadb040b","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":16,"column":5},"end":{"line":16,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 609 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\nError: Call to protected method Models\\User::getId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:369\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\n\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1.\r\n","coveredBy":["a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47","7887ca4a2c4a307323ae55b971671a36","cff255228f49b624005b9e8e6a3187d2"],"killedBy":["cff255228f49b624005b9e8e6a3187d2"],"testsCompleted":7},{"id":"d4afac2dee4549bc7057fa6de12bd6d2","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:285\n\nERRORS!\r\nTests: 9, Assertions: 33, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"c4586d218934bd7438937616f7bef64b","mutatorName":"PublicVisibility","replacement":"protected function getEmail()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nError: Call to protected method Models\\User::getEmail() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\n\nERRORS!\r\nTests: 4, Assertions: 13, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"d0d78774a901d6117ad999da2be37ba0","mutatorName":"PublicVisibility","replacement":"protected function getUserType()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":19,"column":5},"end":{"line":19,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 192 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type\nError: Call to protected method Models\\User::getUserType() from scope Tests\\Unit\\Models\\UserTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:26\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["285178d25eedecfb03dc4c4b6eba6718","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["285178d25eedecfb03dc4c4b6eba6718"],"testsCompleted":1},{"id":"e5b90b3f4e074d77b0ed676214b463d1","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::setName() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:234\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\n\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"02d9ac80d2b13fa177389ece0aeeb701","mutatorName":"PublicVisibility","replacement":"protected function setEmail($email)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::setEmail() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:235\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\n\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"f04b06fb3332a69bbecfe4d2625c948f","mutatorName":"PublicVisibility","replacement":"protected function setPassword($password)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 250 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado\nError: Call to protected method Models\\User::setPassword() from scope Tests\\Unit\\Models\\UserTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:33\n\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1.\r\n","coveredBy":["abcad4aa1b1fdb720f78e696a107cd9d"],"killedBy":["abcad4aa1b1fdb720f78e696a107cd9d"],"testsCompleted":2},{"id":"636131679d0cc337007876fe98ffbb52","mutatorName":"PublicVisibility","replacement":"protected function setUserType($userType)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":27,"column":5},"end":{"line":27,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::setUserType() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:236\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\n\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":9},{"id":"9e85f149773f6c3b40b40c2a55b9a727","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":28,"column":5},"end":{"line":28,"column":34}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47","7887ca4a2c4a307323ae55b971671a36","cff255228f49b624005b9e8e6a3187d2","10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"6a1ef1a1f72f9cc8bf052458a1abe2ae","mutatorName":"This","replacement":"return null;","description":"Replaces a `return $this` statement with `return null` instead.","location":{"start":{"line":30,"column":9},"end":{"line":30,"column":22}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47","7887ca4a2c4a307323ae55b971671a36","cff255228f49b624005b9e8e6a3187d2","10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"76b4ec022036eeb643f458399debb2fd","mutatorName":"PublicVisibility","replacement":"protected function exists($conn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":33,"column":5},"end":{"line":33,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"f367cbf7426f6634d93a91aba2776f0b","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":35,"column":9},"end":{"line":35,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"fc5ecaa69bccd594773448c94ea02af5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":35,"column":9},"end":{"line":35,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"e724cbe39833a8628e1bd0402fac1c8d","mutatorName":"GreaterThan","replacement":"return $stmt->rowCount() >= 0;","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":36,"column":9},"end":{"line":36,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"834309f2522e5360ba85b3cb0d2ca648","mutatorName":"GreaterThanNegotiation","replacement":"return $stmt->rowCount() <= 0;","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":36,"column":9},"end":{"line":36,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0}]}},"testFiles":{"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php":{"tests":[{"id":"a76b01946547645afdff37bedb7a60d8","name":"Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php":{"tests":[{"id":"0035c38ba38c88bdf071f30dece5b1ed","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData"},{"id":"4b7ef0f4842dd40312696d078881bc1b","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings"},{"id":"ed844fdfee0aca4823e723908e1050c1","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted"},{"id":"cbbd507874ef939f3d552fb1d2778eaf","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetOrdersCount"},{"id":"de9e276f8f5c747f061eb9509676c029","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetProductsCount"},{"id":"3db6122e521f4175962773195c0ef118","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetUsersCount"},{"id":"182f23aa48d798ca2b59ec5170288af1","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAdminsCount"},{"id":"e79034ed9db001614c8a06b08fe29564","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalAccounts"},{"id":"04797ba6285e7536bc1672ee1f2993d1","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetMessagesCount"},{"id":"1fcbaae12f7aa2a9842563778effa4b8","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleDatabaseError"},{"id":"29b79fb297244e4a16f3feec06d710f8","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName"},{"id":"0ef74689b85933c5d3549fbc2e5dea1d","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully"},{"id":"09d8bcdc9cfda619b9c89a29648d2d8e","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct"},{"id":"da270c190fd61906ead367a1ea0887d7","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension"},{"id":"4a940269ad09ef1eaa1ca8bf8babb532","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath"},{"id":"18df9e78a83ffa99f0e870e79d11a7ef","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName"},{"id":"d736e3db7bd2dbf25459d31155b47535","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDelete"},{"id":"1687539f841ed1e27e155d1c2fb94f65","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct"},{"id":"fdc4d9a06f09a8929a91ed6665707728","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError"},{"id":"6f545f29a2bbd15c0e463d582b40e0e6","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithoutImage"},{"id":"57253b9d08a8f0a9941004a0ce8690f2","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage"},{"id":"cf7867dae1c09fe7077fa87406af264c","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts"},{"id":"e137814adcd8c47231462a635b04946e","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders"},{"id":"e10152eb56d82638400e2423c572cdc4","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatusDatabaseError"},{"id":"9cf07fc703009bc41d2d6794677c2465","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus"},{"id":"9f4d645aba7ebec46f8fa49817ad0027","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder"},{"id":"10855cefec4f27ff428351644efe1527","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers"},{"id":"cff255228f49b624005b9e8e6a3187d2","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser"},{"id":"36243924380b2e3a203435fb9bdce1d1","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages"},{"id":"111d21c767467e138a3e41568fbcceab","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\AdminControllerMutationTest.php":{"tests":[{"id":"2d96172708d0af33b9c3e772691740b7","name":"Tests\\Mutation\\AdminControllerMutationTest::testAddProductMutation"},{"id":"bc679a7bfa1a66d938d5ff57e1539d14","name":"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductMutation"},{"id":"cdfbf1ee9d72c63df39b6798ffcd74bd","name":"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductMutation"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php":{"tests":[{"id":"5088f3b11ad49667e4f9a7b896a88ede","name":"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithInvalidUserId"},{"id":"b488b34d4881115bec02ef8105e30716","name":"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithMissingFields"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php":{"tests":[{"id":"5aeab43d6bb5e254f77e2aa5dac28edb","name":"Tests\\Unit\\Controllers\\ContactControllerTest::crear_usuario_retorna_instancia_user"},{"id":"68e73fbb4670258440901c3a46e2064d","name":"Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message"},{"id":"d59917b2d5528ca6063952ee4f1d097b","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_user_id"},{"id":"dadb1321b7b0db79872fdfdbe6115493","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar"},{"id":"1a5c37673a34ba1e37ac2923b430a4e6","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado"},{"id":"b93f5bfed89d4ed88cd4c8765ceac045","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_campos_faltantes"},{"id":"c7648c8a27ed50c48a0d2328c2890535","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_maneja_error_en_save"},{"id":"76926558c21488fe35e209f0ecda409e","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion"},{"id":"966624d19ce2dba3bed3eccf1c0f956f","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_usuario_no_encontrado"},{"id":"aa989a99b189876d061fe9ba83f42bce","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters"},{"id":"9ebb033692c3de0faab3cd111369f928","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php":{"tests":[{"id":"ceb6936c11cf19bb44e528fa327f0416","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos"},{"id":"40ff0078972e38dca8cfb4be5e49a3b0","name":"Tests\\Unit\\Controllers\\OrderControllerTest::actualizar_estado_pago"},{"id":"452ca6af2bdb570f2ff036e996e62a49","name":"Tests\\Unit\\Controllers\\OrderControllerTest::eliminar_pedido"},{"id":"b989a99ca1b325941722866a40278e06","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos"},{"id":"69742414b49277efb4ce0f433c788e09","name":"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido"},{"id":"9b1d437f68a23ef8f0c60f232232f51c","name":"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_carrito_vacio"},{"id":"d274c529f48ebd0c0d2e7e82410e3415","name":"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado"},{"id":"7a701a7b1ab59a11ed7dcb7f27545ae6","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido"},{"id":"27e8ba2c551cff1a3e7129fa7a38a940","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario"},{"id":"116e55b7e31c4b7eb431eadb6fd89108","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_productos"},{"id":"0dbb68598d76d4d127b823247b0e445a","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos"},{"id":"b388534ee189eeb5ea1ebdd33ff1fb04","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_usuarios"},{"id":"aca810d1d7530667d800dd6115dd2020","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php":{"tests":[{"id":"ac9ac5f42f33e350edbcf6e51247ed95","name":"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusMutation"},{"id":"9112c9fc2d730bc2c02af9b6785500ea","name":"Tests\\Mutation\\OrderControllerMutationTest::testDeleteOrderMutation"},{"id":"17fc22fdee4bdc93146edb702b18eb90","name":"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutationWithEmptyCart"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php":{"tests":[{"id":"feb6d707c4d8182bd8ec66df03f90917","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_productos_recientes"},{"id":"1e6370b34d1434c9c300fcc4dade9a01","name":"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes"},{"id":"6fe2e83f565ec7dff367868cae77e679","name":"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_producto_duplicado_al_carrito"},{"id":"21b277a20d75495834b915634005099f","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito"},{"id":"496122c302addcbe11f203caffa7d24f","name":"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito"},{"id":"96cb93ace2fec2f94dda2e1aac950bbc","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_todos_productos"},{"id":"cb81a55cafc96c5e140058f48b76748b","name":"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos"},{"id":"5144a3795216d9768bcf2e1b0de52d7c","name":"Tests\\Unit\\Controllers\\ProductControllerTest::verificar_carrito_vacio"},{"id":"47942d6a996427c3c1cec9efff6173b2","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_items_carrito"},{"id":"242f299f525da768f9961477f538fcf7","name":"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito"},{"id":"861ce129fc3196e3f58b8d7dc15e77f8","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_actualizar_cantidad"},{"id":"fc8f4ab810696c7119210820c8dcb994","name":"Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso"},{"id":"8b777577a59cbaa568701bb5fa606fc0","name":"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso"},{"id":"8d3a5cdebb924a18bbd6039914683cec","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_item_carrito"},{"id":"9079b2b01975467bd588ac0635613e00","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito"},{"id":"533c884852c9465706da5a94e08ac4b2","name":"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php":{"tests":[{"id":"dc7b02abddb2408e22973baf42d4b091","name":"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartMutationWithDuplicate"},{"id":"dbc96c03f3b64a74b10909e936648484","name":"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityMutation"},{"id":"90d2b1363c2387d208e61551e5d81906","name":"Tests\\Mutation\\ProductControllerMutationTest::testDeleteCartItemMutation"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php":{"tests":[{"id":"119dcc727a6c5c37089ce369397e3936","name":"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_no_hay_resultados"},{"id":"38f507e5499b7d283bd2d73a0e5dab72","name":"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados"},{"id":"9499b5d588e5718df0bbb5d28d1d7337","name":"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_hay_excepcion"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php":{"tests":[{"id":"4e5d456bcd3f0f480afe371d6ab58a3a","name":"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse"},{"id":"c6a72142a437ffdb72dd509a3961171c","name":"Tests\\Unit\\Controllers\\UserControllerTest::registro_con_tipo_usuario_personalizado"},{"id":"c5f619a697779b293907d101b23e2cc5","name":"Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto"},{"id":"7e8c90fdba931569ce4b61319939fb43","name":"Tests\\Unit\\Controllers\\UserControllerTest::verificar_hash_password"},{"id":"74d98ff831c11e5975e82c1f78463f05","name":"Tests\\Unit\\Controllers\\UserControllerTest::registro_exitoso_sin_tipo_usuario"},{"id":"5f1ac69ed727a6a2093d161091ef2238","name":"Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register"},{"id":"1f53110b52fbcb82fad3d83ce886911f","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_password_incorrecto"},{"id":"e90d3c5d6475a8b9876cd1a2fd342fc2","name":"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_correcto"},{"id":"c0b609be3f46cabd11f9479c3867ba10","name":"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_incorrecto"},{"id":"7e243c64fb424b58831479362b095622","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_nombre_en_sesion"},{"id":"f68eb8b986d9fc309ed29c287efd52cb","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_password_incorrecto"},{"id":"2c9e012a8ef82162dc733a7d5ed147cb","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_exitoso_con_admin"},{"id":"bc66590a599c81f251afe7f022704124","name":"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion"},{"id":"7a41cc8095f8763e256eeeabc2964148","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_tipo_usuario_en_sesion"},{"id":"cf7f861e585d3046cc970897756c7229","name":"Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente"},{"id":"5562fefd1e6267f1330a8be9c24c0c1e","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_email_existente"},{"id":"1648e182f0dec8698cc3c000b7c001fe","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_error_db"},{"id":"1884bc4f1d1fef63116444d66c172e6b","name":"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro"},{"id":"88913d5fb1ca58b323af46d3e38f8b37","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_error_db"},{"id":"377db5af9ac5ffe374c7f038544ba613","name":"Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas"},{"id":"dc1973acbaca0a28a598effc18237ad0","name":"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login"},{"id":"f94ca319ab2dfc219b33dcd743cfeb5f","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_credenciales_invalidas"},{"id":"a3214e814150e4694e5bde76166b4a2b","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_usuario_no_existe"},{"id":"6511508b57f48da46af4c82281794cb0","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_con_error_db"},{"id":"baeba2b0443c9006dae99054a84bf92d","name":"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_al_obtener_usuario"},{"id":"ebc491f7be9fdad3965e5ccdf30566c6","name":"Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id"},{"id":"62b48a5e15de8d584745b990f5316ddb","name":"Tests\\Unit\\Controllers\\UserControllerTest::obtener_usuario_inexistente"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Exceptions\\DatabaseExceptionTest.php":{"tests":[{"id":"14c8f43f9e245c169de43a060ab0f2de","name":"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::hereda_de_exception"},{"id":"bdebf4104aab33e53ad818316cae31d9","name":"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_sin_parametros"},{"id":"9a69dda033b5b96b3a4d273cef8d5e4d","name":"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_con_parametros"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php":{"tests":[{"id":"526a8af9ac30be501c7f4b37124d576f","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id"},{"id":"982c4d44a4015074431dc655f61bf9c9","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id"},{"id":"2b1642fa5d7b37210b33ee2a94697390","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name"},{"id":"19542864ba4ef81044cd17038a6e8c59","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email"},{"id":"acf82b784e1fde7256a6c27e70355a65","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number"},{"id":"83c78b91f60c0ee0e7c5af4cda4ca08c","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message"},{"id":"4813abd1aac2f55ae34e6218d3266a72","name":"Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje"},{"id":"09cbcccec0a12bf6ed83725861831d3b","name":"Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia"},{"id":"9fac10250403152dbfd443e6d82c8728","name":"Tests\\Unit\\Models\\MessageTest::maneja_error_al_guardar"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php":{"tests":[{"id":"a2abfd90bc3ac1aaedbe1b522cdb7564","name":"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_false_cuando_no_existe"},{"id":"ecf5c7e40cfc13af5d0ff47e2cb25e47","name":"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_true_cuando_existe"},{"id":"7887ca4a2c4a307323ae55b971671a36","name":"Tests\\Unit\\Models\\UserTest::verifica_setId_retorna_instancia"},{"id":"285178d25eedecfb03dc4c4b6eba6718","name":"Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type"},{"id":"abcad4aa1b1fdb720f78e696a107cd9d","name":"Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado"}]}},"framework":{"name":"Infection","branding":{"homepageUrl":"https:\/\/infection.github.io\/","imageUrl":"https:\/\/infection.github.io\/images\/logo.png"}}} + document.getElementsByTagName('mutation-test-report-app').item(0).report = {"schemaVersion":"1","thresholds":{"high":90,"low":50},"files":{"Config\/Database.php":{"language":"php","source":"setDefaultCredentials();\r\n return;\r\n }\r\n\r\n $envPath = __DIR__ . '\/..\/..\/.env';\r\n \r\n if (file_exists($envPath)) {\r\n $env = parse_ini_file($envPath);\r\n if ($env !== false) {\r\n $this->host = $env['DB_HOST'];\r\n $this->user = $env['DB_USER'];\r\n $this->password = $env['DB_PASSWORD'];\r\n $this->database = $env['DB_NAME'];\r\n return;\r\n }\r\n }\r\n\r\n $this->setDefaultCredentials();\r\n }\r\n\r\n private function setDefaultCredentials(): void\r\n {\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n }\r\n\r\n public function setCredentials(string $host, string $user, string $password, string $database): void\r\n {\r\n $this->host = $host;\r\n $this->user = $user;\r\n $this->password = $password;\r\n $this->database = $database;\r\n }\r\n\r\n public function connect() {\r\n try {\r\n $conn = new \\PDO(\r\n \"mysql:host={$this->host};dbname={$this->database}\",\r\n $this->user,\r\n $this->password,\r\n array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\")\r\n );\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch(\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n throw new DatabaseException(\r\n \"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(),\r\n $e->getCode(),\r\n $e\r\n );\r\n }\r\n }\r\n} ","mutants":[{"id":"70f1a9a59c136dc0d10a0f0a6c1697e9","mutatorName":"TrueValue","replacement":"public function __construct(bool $useEnv = false)","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":13,"column":5},"end":{"line":13,"column":55}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"6e33f7a90aec2dd3bafe8e4e439e6df3","mutatorName":"LogicalNot","replacement":"if ($useEnv) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":14,"column":9},"end":{"line":14,"column":24}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 192 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.014, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\nfopen(C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\.env): Failed to open stream: Permission denied\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php:113\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php:20\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:14\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["a76b01946547645afdff37bedb7a60d8"],"testsCompleted":1},{"id":"669ea3810b5da00a195baa730423ebbf","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":15,"column":13},"end":{"line":15,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.709, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\nFailed asserting that null matches expected 'test_host'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\n\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["02fbcb9d639939cd105b73916f225638"],"testsCompleted":2},{"id":"e1590fd490676ae96b38f1f60eaddf07","mutatorName":"Ternary","replacement":"$this->host = getenv('DB_HOST') ? 'db' : getenv('DB_HOST');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":37,"column":9},"end":{"line":37,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.706, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'test_host'\n+'db'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\n\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["02fbcb9d639939cd105b73916f225638"],"testsCompleted":2},{"id":"ac150f0f10afad8a9d133140b5b51473","mutatorName":"Ternary","replacement":"$this->user = getenv('DB_USER') ? 'root' : getenv('DB_USER');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":38,"column":9},"end":{"line":38,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 398 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.704, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_valores_por_defecto_cuando_no_hay_env\nFailed asserting that false matches expected 'root'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:58\n\nFAILURES!\r\nTests: 3, Assertions: 4, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["699053407dfadfed887cd7fe49d05704"],"testsCompleted":3},{"id":"2b951f552d97bcf2549e46804adbbdd0","mutatorName":"Ternary","replacement":"$this->password = getenv('DB_PASSWORD') ? '123456' : getenv('DB_PASSWORD');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":39,"column":9},"end":{"line":39,"column":61}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"62a742f983e86a68b6abd4ea9883de4a","mutatorName":"Ternary","replacement":"$this->database = getenv('DB_NAME') ? 'tienda_bd' : getenv('DB_NAME');","description":"Swaps the ternary operator operands, e.g. replaces `true ? true : false` with `true ? false : true`.","location":{"start":{"line":40,"column":9},"end":{"line":40,"column":60}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"a87a35d49977e33c6b280db307f1f05d","mutatorName":"PublicVisibility","replacement":"protected function connect()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":51,"column":5},"end":{"line":51,"column":32}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\nFailed asserting that exception of type \"Error\" matches expected exception \"Exceptions\\DatabaseException\". Message was: \"Call to protected method Config\\Database::connect() from scope Tests\\Unit\\Config\\DatabaseTest\" at\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:18\n.\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["a76b01946547645afdff37bedb7a60d8"],"testsCompleted":1},{"id":"c98cd08563143260c5b320d7c78d4e1b","mutatorName":"ArrayItemRemoval","replacement":"$conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array());","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":57,"column":17},"end":{"line":57,"column":73}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"019dc92121994ab88079699df3104e75","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error de conexi\u00f3n: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"bbe2dc76e2b8b26fc5ada51ba5a5c280","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"3f6d9e7a1e32c9f34d4700f42fdd4024","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error de conexi\u00f3n: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"d9e21d473ce4762b7918183ad5c73f44","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":66}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"105f009b665fcf6459812bb31e716ba4","mutatorName":"Throw_","replacement":"new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":63,"column":13},"end":{"line":67,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.714, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\nFailed asserting that exception of type \"Exceptions\\DatabaseException\" is thrown.\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":["a76b01946547645afdff37bedb7a60d8"],"testsCompleted":1},{"id":"e3fc12ceee3690e94399dad1355ee1ab","mutatorName":"Concat","replacement":"throw new DatabaseException($e->getMessage() . \"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":64,"column":17},"end":{"line":64,"column":78}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"7c750a88ac3855fb5d0279d429e3d6cc","mutatorName":"ConcatOperandRemoval","replacement":"throw new DatabaseException($e->getMessage(), $e->getCode(), $e);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":64,"column":17},"end":{"line":64,"column":78}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0},{"id":"9010c6395295030139fd9d6d72d4d25f","mutatorName":"ConcatOperandRemoval","replacement":"throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":64,"column":17},"end":{"line":64,"column":78}},"status":"Timeout","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....S","coveredBy":["a76b01946547645afdff37bedb7a60d8"],"killedBy":[],"testsCompleted":0}]},"Controllers\/AdminController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function getDashboardData() {\r\n $data = [];\r\n \r\n \/\/ Obtener total pendientes\r\n $data['total_pendings'] = $this->getTotalPendings();\r\n $data['total_completed'] = $this->getTotalCompleted();\r\n $data['orders_count'] = $this->getOrdersCount();\r\n $data['products_count'] = $this->getProductsCount();\r\n $data['users_count'] = $this->getUsersCount();\r\n $data['admins_count'] = $this->getAdminsCount();\r\n $data['total_accounts'] = $this->getTotalAccounts();\r\n $data['messages_count'] = $this->getMessagesCount();\r\n\r\n return $data;\r\n }\r\n\r\n public function getTotalPendings() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n $stmt->execute();\r\n $total = 0;\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n }\r\n }\r\n\r\n private function getTotalCompleted() {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n $stmt->execute();\r\n $total = 0;\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;\r\n }\r\n\r\n private function getOrdersCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getProductsCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `products`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getUsersCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getAdminsCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getTotalAccounts() {\r\n $query = \"SELECT COUNT(*) as count FROM `users`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function getMessagesCount() {\r\n $query = \"SELECT COUNT(*) as count FROM `message`\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n\r\n private function handleDatabaseError($e) {\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n\r\n public function addProduct($postData, $files) {\r\n try {\r\n $product = new Product();\r\n $product->setName($postData['name']);\r\n $product->setPrice($postData['price']);\r\n $product->setImage($files['image']['name']);\r\n\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n \r\n if($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n\r\n if($files['image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\r\n }\r\n }\r\n\r\n public function deleteProduct($id) {\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen\r\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\r\n $stmt->execute([$id]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n \r\n if($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\r\n if(file_exists($imagePath)) {\r\n unlink($imagePath);\r\n }\r\n }\r\n \r\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\r\n if($stmt->execute([$id])) {\r\n return ['success' => true, 'message' => 'Producto eliminado'];\r\n }\r\n \r\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\r\n } catch (\\Exception $e) {\r\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\r\n }\r\n }\r\n\r\n private function validateImageName($imageName) {\r\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\r\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\r\n }\r\n\r\n private function getSecureImagePath($imageName) {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\r\n }\r\n\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\r\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n throw new \\Exception('Tipo de archivo no permitido');\r\n }\r\n\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n $stmt->execute([$imageName]);\r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n private function handleImageDelete($imageName) {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n return false;\r\n }\r\n\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n $stmt->execute([$imageName]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n\r\n if (!$result) {\r\n return false;\r\n }\r\n\r\n \/\/ Construir y validar la ruta\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n return false;\r\n }\r\n\r\n \/\/ Eliminar el archivo si existe\r\n if (file_exists($fullPath)) {\r\n return unlink($fullPath);\r\n }\r\n\r\n return false;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function updateProduct($postData, $files) {\r\n try {\r\n $product = new Product();\r\n $product->setId($postData['update_p_id']);\r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n \r\n if(!empty($files['update_image']['name'])) {\r\n if($files['update_image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {\r\n $this->handleImageDelete($postData['update_old_image']);\r\n }\r\n\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \r\n \/\/ Subir nueva imagen\r\n move_uploaded_file(\r\n $files['update_image']['tmp_name'], \r\n self::UPLOAD_PATH . $newImageName\r\n );\r\n \r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\r\n }\r\n \r\n if($stmt->execute($params)) {\r\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\r\n }\r\n \r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en updateProduct: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n }\r\n }\r\n\r\n public function getAllProducts() {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n }\r\n\r\n public function getAllOrders() {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n }\r\n\r\n public function updateOrderStatus($orderId, $status) {\r\n try {\r\n $order = new Order();\r\n $order->setId($orderId);\r\n $order->setPaymentStatus($status);\r\n \r\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n\r\n public function deleteOrder($orderId) {\r\n try {\r\n $order = new Order();\r\n $order->setId($orderId);\r\n \r\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\r\n return $stmt->execute([$order->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n\r\n public function getAllUsers() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n \r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }\r\n return $users;\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function deleteUser($userId) {\r\n try {\r\n $user = new User();\r\n $user->setId($userId);\r\n \r\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\r\n return $stmt->execute([$user->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n\r\n public function getAllMessages() {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\r\n $messages = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);\r\n $message->setNumber($row['number']);\r\n $messages[] = $message;\r\n }\r\n return $messages;\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function deleteMessage($messageId) {\r\n try {\r\n $query = \"DELETE FROM `message` WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n return $stmt->execute([$messageId]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;\r\n }\r\n }\r\n} ","mutants":[{"id":"9268c86e87530f1be2a3a1f4930e7bc8","mutatorName":"PublicVisibility","replacement":"protected function getDashboardData()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":20,"column":5},"end":{"line":20,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\nError: Call to protected method Controllers\\AdminController::getDashboardData() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["0035c38ba38c88bdf071f30dece5b1ed"],"testsCompleted":1},{"id":"024720b0058d851c71253877a869e9d4","mutatorName":"PublicVisibility","replacement":"protected function getTotalPendings()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":36,"column":5},"end":{"line":36,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................E\nNotice: fwrite(): Write of 2731 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::obtener_total_pendientes_exitoso\nError: Call to protected method Controllers\\AdminController::getTotalPendings() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:721\n\nERRORS!\r\nTests: 34, Assertions: 69, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["a7cb58e5c148750d37ad32c09b2b8ea0"],"testsCompleted":34},{"id":"61962ebb2c2c0b077be680428b720094","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":39,"column":13},"end":{"line":39,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................F\nNotice: fwrite(): Write of 2735 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::obtener_total_pendientes_exitoso\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 34, Assertions: 72, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["a7cb58e5c148750d37ad32c09b2b8ea0"],"testsCompleted":34},{"id":"cc766f32a22bcfe6567fbc55c63dd397","mutatorName":"DecrementInteger","replacement":"$total = -1;","description":"Decrements an integer value with 1.","location":{"start":{"line":40,"column":13},"end":{"line":40,"column":24}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 249.0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"cae509ac1b37de93001c0366ce6ce64d","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":41,"column":13},"end":{"line":46,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1116 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"b0b1dccd67d72ad8f84c3329314d3ca8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":43,"column":17},"end":{"line":43,"column":43}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2749 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"79491ca4e8276a75ad283d9986a86ab7","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":44,"column":17},"end":{"line":44,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\nFailed asserting that 0 matches expected 250.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\n\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["4b7ef0f4842dd40312696d078881bc1b"],"testsCompleted":14},{"id":"83e72ccb8915bfba9f3a171f78222acb","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":55,"column":9},"end":{"line":55,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2753 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"171baa165cd80df3fe23c2c07cd10b18","mutatorName":"DecrementInteger","replacement":"$total = -1;","description":"Decrements an integer value with 1.","location":{"start":{"line":56,"column":9},"end":{"line":56,"column":20}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1194 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that 499.0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"1e1ca804e91d6e0012a0d9a7d03e3d1c","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":57,"column":9},"end":{"line":62,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1190 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\nFailed asserting that 0 matches expected 500.0.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\n\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1.\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":["ed844fdfee0aca4823e723908e1050c1"],"testsCompleted":15},{"id":"ffbc9b4859e457628f75f516e809310c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["ed844fdfee0aca4823e723908e1050c1","0035c38ba38c88bdf071f30dece5b1ed"],"killedBy":[],"testsCompleted":0},{"id":"06a47dcca3e2b8cdc37d056841b0b984","mutatorName":"PublicVisibility","replacement":"protected function addProduct($postData, $files)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":113,"column":5},"end":{"line":113,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 335 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nError: Call to protected method Controllers\\AdminController::addProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\n\nERRORS!\r\nTests: 3, Assertions: 6, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"f44ec47921361b3ea4c846c3ef3201fb","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":117,"column":13},"end":{"line":117,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":0},{"id":"7326e77d4b4a8e18c8c86361e2c5eb5c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":57}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":0},{"id":"c9a796ebff25332fbc29f423e3a32d75","mutatorName":"GreaterThan","replacement":"if ($stmt->rowCount() >= 0) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":124,"column":13},"end":{"line":124,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 7, Failures: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"efd964bcae992a8ac97432e2fab10d37","mutatorName":"GreaterThanNegotiation","replacement":"if ($stmt->rowCount() <= 0) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":124,"column":13},"end":{"line":124,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 7, Failures: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"ea2070656fe2254417f45d01c9f122bc","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El producto ya existe'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":125,"column":17},"end":{"line":125,"column":83}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n. 1 \/ 1 (100%)\nNotice: fwrite(): Write of 101 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.009, Memory: 8.00 MB\r\n\r\nOK (1 test, 1 assertion)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7"],"killedBy":[],"testsCompleted":0},{"id":"47c751d3cc027a2ebe0385deaf8e6082","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El producto ya existe'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":125,"column":17},"end":{"line":125,"column":83}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n. 1 \/ 1 (100%)\nNotice: fwrite(): Write of 101 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.007, Memory: 8.00 MB\r\n\r\nOK (1 test, 1 assertion)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7"],"killedBy":[],"testsCompleted":0},{"id":"8334d7a10c78e9bb44e1457f695babb0","mutatorName":"GreaterThan","replacement":"if ($files['image']['size'] >= 2000000) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":128,"column":13},"end":{"line":128,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2810 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":0},{"id":"0b10872d614f522331a60d20b41ed2b8","mutatorName":"GreaterThanNegotiation","replacement":"if ($files['image']['size'] <= 2000000) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":128,"column":13},"end":{"line":128,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\n\nFAILURES!\r\nTests: 3, Assertions: 7, Failures: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"5b406d2bf27b88acd5b908c36a209788","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":129,"column":17},"end":{"line":129,"column":105}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":0},{"id":"3587dad72b3f70afd6aee05956863b5b","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":129,"column":17},"end":{"line":129,"column":105}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","0ef74689b85933c5d3549fbc2e5dea1d"],"killedBy":[],"testsCompleted":0},{"id":"ceecc50a8244a9f79632383cbb1adb57","mutatorName":"PublicVisibility","replacement":"protected function deleteProduct($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":143,"column":5},"end":{"line":143,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 544 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\nError: Call to protected method Controllers\\AdminController::deleteProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:127\n\nERRORS!\r\nTests: 6, Assertions: 15, Errors: 1.\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":["09d8bcdc9cfda619b9c89a29648d2d8e"],"testsCompleted":6},{"id":"3fbb477c3937557ae6765c3874c1e896","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":147,"column":13},"end":{"line":147,"column":35}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2818 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":0},{"id":"db2e53801c2ace623938e196414f2510","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":147,"column":13},"end":{"line":147,"column":35}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2813 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":0},{"id":"060413cf4720be9ac624038e350e9310","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":153,"column":21},"end":{"line":153,"column":40}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2818 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["bc679a7bfa1a66d938d5ff57e1539d14","09d8bcdc9cfda619b9c89a29648d2d8e"],"killedBy":[],"testsCompleted":0},{"id":"a712b238d556edb312060d49d232ef82","mutatorName":"Throw_","replacement":"new \\Exception('Nombre de archivo inv\u00e1lido');","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":177,"column":17},"end":{"line":177,"column":69}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............................E\nNotice: fwrite(): Write of 2487 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathWithEmptyAndNonStringName\nTypeError: pathinfo(): Argument #1 ($path) must be of type string, array given\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:171\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:638\n\nERRORS!\r\nTests: 31, Assertions: 60, Errors: 1.\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7","4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["322b43a847864311010b3375f62d2d76"],"testsCompleted":31},{"id":"5d8898d4eed0b34f06b5a7c0f72ebbd0","mutatorName":"Throw_","replacement":"new \\Exception('Tipo de archivo no permitido');","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":183,"column":17},"end":{"line":183,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........................E\nNotice: fwrite(): Write of 1956 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension\nError: Call to a member function execute() on bool\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:177\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:516\n\nERRORS!\r\nTests: 25, Assertions: 49, Errors: 1.\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["da270c190fd61906ead367a1ea0887d7"],"testsCompleted":25},{"id":"2fe3433e5cafcd3223ddf53ce1b9a426","mutatorName":"LogicalNot","replacement":"if ($stmt->fetch()) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":189,"column":13},"end":{"line":189,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................F\nNotice: fwrite(): Write of 1854 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\nFailed asserting that false is not false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\n\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1.\r\n","coveredBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"killedBy":["4a940269ad09ef1eaa1ca8bf8babb532"],"testsCompleted":24},{"id":"3fc6b3bfb395214b4c51693d0fd2c7b7","mutatorName":"Throw_","replacement":"new \\Exception('Archivo no encontrado en la base de datos');","description":"Removes a throw statement (`throw`). For example:\n\n```php\nthrow new Exception();\n```\n\nWill be mutated to:\n\n```php\nnew Exception();\n```\n","location":{"start":{"line":190,"column":17},"end":{"line":190,"column":83}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2753 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["da270c190fd61906ead367a1ea0887d7"],"killedBy":[],"testsCompleted":0},{"id":"e741512c721c1d8219039f2d61088bb2","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":204,"column":17},"end":{"line":204,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........................F\nNotice: fwrite(): Write of 2172 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:548\n\nFAILURES!\r\nTests: 28, Assertions: 53, Failures: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["18df9e78a83ffa99f0e870e79d11a7ef"],"testsCompleted":28},{"id":"1b79defd45f6e223e7b3e7ff6784b90d","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":209,"column":13},"end":{"line":209,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"105d1fb6b3220a9b6ecbb62332eedbe3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":209,"column":13},"end":{"line":209,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2753 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"35fd22af4c32e5d1a8fadcd6a4f13351","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":213,"column":17},"end":{"line":213,"column":30}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":0},{"id":"06d6949d107e1f372ece53896bd39162","mutatorName":"Concat","replacement":"$fullPath = realpath($result['image'] . self::UPLOAD_PATH);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":0},{"id":"a1e11ab42d547b03b675ac3dc8a7b9e0","mutatorName":"ConcatOperandRemoval","replacement":"$fullPath = realpath($result['image']);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":0},{"id":"29d149823552a5625710e1d4bd15b851","mutatorName":"ConcatOperandRemoval","replacement":"$fullPath = realpath(self::UPLOAD_PATH);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":217,"column":13},"end":{"line":217,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","d736e3db7bd2dbf25459d31155b47535"],"killedBy":[],"testsCompleted":0},{"id":"01843224dca4f2ed11e975200a75996a","mutatorName":"PublicVisibility","replacement":"protected function updateProduct($postData, $files)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":237,"column":5},"end":{"line":237,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........E\nNotice: fwrite(): Write of 959 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nError: Call to protected method Controllers\\AdminController::updateProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\n\nERRORS!\r\nTests: 12, Assertions: 28, Errors: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"e498ade5e0a63c792ef20f8bc84b2055","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":240,"column":13},"end":{"line":240,"column":55}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"2701cf2e9997b8f4a1a2d7c6937a0fa6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":241,"column":13},"end":{"line":241,"column":57}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2813 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","57253b9d08a8f0a9941004a0ce8690f2","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"41a3600cfbea613d84245880205c712b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":242,"column":13},"end":{"line":242,"column":59}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2749 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["57253b9d08a8f0a9941004a0ce8690f2"],"killedBy":[],"testsCompleted":0},{"id":"966fa07ad12f59e3601798161e845eb6","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":246,"column":21},"end":{"line":246,"column":109}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................F\nNotice: fwrite(): Write of 1850 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\n\nFAILURES!\r\nTests: 24, Assertions: 47, Failures: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["57253b9d08a8f0a9941004a0ce8690f2"],"testsCompleted":24},{"id":"fc79800156867d641c3914ad36601a9a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":246,"column":21},"end":{"line":246,"column":109}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......................E\nNotice: fwrite(): Write of 1853 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\n\nERRORS!\r\nTests: 24, Assertions: 46, Errors: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["57253b9d08a8f0a9941004a0ce8690f2"],"testsCompleted":24},{"id":"22fc4ccbb5dc9a46900837fed13fc9a8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":251,"column":21},"end":{"line":251,"column":77}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"51bbd55665cd3dee4c21e796f21c675d","mutatorName":"Concat","replacement":"$newImageName = '.' . uniqid() . $extension;","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":256,"column":17},"end":{"line":256,"column":61}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"fccd842f3bc87b1d5a9629d35f97d939","mutatorName":"ConcatOperandRemoval","replacement":"$newImageName = '.' . $extension;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":256,"column":17},"end":{"line":256,"column":61}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"dad4fe1c165d0b6ab81be58ebf27f22c","mutatorName":"ConcatOperandRemoval","replacement":"$newImageName = uniqid() . $extension;","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":256,"column":17},"end":{"line":256,"column":61}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"edf3383b60bdc90f6ee242722ce0baf2","mutatorName":"Concat","replacement":"$newImageName = uniqid() . $extension . '.';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":256,"column":17},"end":{"line":256,"column":61}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"17d075d84386b51c01b4adec479b4a0c","mutatorName":"ConcatOperandRemoval","replacement":"$newImageName = uniqid() . '.';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":256,"column":17},"end":{"line":256,"column":61}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"1260a070424e3cadb2e22a2f75fc1f0b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":257,"column":17},"end":{"line":257,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"70964f28b7fc370bc56a1a47c27e529e","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":260,"column":17},"end":{"line":263,"column":36}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.067, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"43b410f0491bc58c56a81a3f9df3d2c2","mutatorName":"Concat","replacement":"move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH);","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":262,"column":21},"end":{"line":262,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"f823093009c2bb2aaa7019d837d1f33d","mutatorName":"ConcatOperandRemoval","replacement":"move_uploaded_file($files['update_image']['tmp_name'], $newImageName);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":262,"column":21},"end":{"line":262,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"c2b5ab121ed74a9d10b156bd78397b85","mutatorName":"ConcatOperandRemoval","replacement":"move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":262,"column":21},"end":{"line":262,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.074, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"9541a7fba1594de3b540e12fe5c58de2","mutatorName":"ArrayItemRemoval","replacement":"$params = [$product->getPrice(), $product->getId()];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":269,"column":17},"end":{"line":269,"column":90}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................................... 36 \/ 36 (100%)\nNotice: fwrite(): Write of 2846 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.074, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","6f545f29a2bbd15c0e463d582b40e0e6","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":[],"testsCompleted":0},{"id":"48e42c6f3b0390f6d7715265798dc0ba","mutatorName":"PublicVisibility","replacement":"protected function getAllProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":283,"column":5},"end":{"line":283,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 826 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nError: Call to protected method Controllers\\AdminController::getAllProducts() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:212\n\nERRORS!\r\nTests: 10, Assertions: 23, Errors: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"52cfd83843142a97148ee19bb4789d31","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":286,"column":9},"end":{"line":293,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nFailed asserting that actual size 0 matches expected size 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:215\n\nFAILURES!\r\nTests: 10, Assertions: 25, Failures: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"e483c2a87b54aea6cbf3926649736bc8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":288,"column":13},"end":{"line":288,"column":41}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":[],"testsCompleted":0},{"id":"8a9d48fc33e813fcc3d04dba3ad2c5ca","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":290,"column":13},"end":{"line":290,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 829 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\nFailed asserting that null matches expected 99.99.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:217\n\nFAILURES!\r\nTests: 10, Assertions: 27, Failures: 1.\r\n","coveredBy":["cf7867dae1c09fe7077fa87406af264c"],"killedBy":["cf7867dae1c09fe7077fa87406af264c"],"testsCompleted":10},{"id":"033dca71b2ba96cc19083d783d302498","mutatorName":"PublicVisibility","replacement":"protected function getAllOrders()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":297,"column":5},"end":{"line":297,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........E\nNotice: fwrite(): Write of 957 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nError: Call to protected method Controllers\\AdminController::getAllOrders() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:270\n\nERRORS!\r\nTests: 12, Assertions: 29, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"2733b2a4eba8b3463fb9777ee9710738","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":299,"column":9},"end":{"line":299,"column":26}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"03902f306323234e4c1e05679f928d10","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":301,"column":9},"end":{"line":315,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 965 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nFailed asserting that actual size 0 matches expected size 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:273\n\nFAILURES!\r\nTests: 12, Assertions: 31, Failures: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"ae16058f862e616828fb45b96364d730","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":303,"column":13},"end":{"line":303,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"717e36ce6e2580b4704a0f1547e13206","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":304,"column":13},"end":{"line":304,"column":48}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2765 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.057, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"6d81e20b9bf487f6df54643f76805e18","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":305,"column":13},"end":{"line":305,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"bde623e62bec333977a02adec7bdcc9b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":306,"column":13},"end":{"line":306,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 961 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\nFailed asserting that null matches expected 'Customer 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:274\n\nFAILURES!\r\nTests: 12, Assertions: 32, Failures: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":["e137814adcd8c47231462a635b04946e"],"testsCompleted":12},{"id":"eaea125e6972339348e7814254d4b22f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":307,"column":13},"end":{"line":307,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2764 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"48b3bc6cb75923b5e113444af76042ae","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":308,"column":13},"end":{"line":308,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"269f102acbcb6b17afcb841fdeef51c9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":309,"column":13},"end":{"line":309,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2749 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"a863f64fe43af3c210709deb8905b82a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":310,"column":13},"end":{"line":310,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"84d8c85c008ee0fefd2944e7aa4e53ee","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":312,"column":13},"end":{"line":312,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e137814adcd8c47231462a635b04946e"],"killedBy":[],"testsCompleted":0},{"id":"d7daf7aa1e2be057a8d0d943c467a125","mutatorName":"PublicVisibility","replacement":"protected function updateOrderStatus($orderId, $status)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":319,"column":5},"end":{"line":319,"column":59}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\nError: Call to protected method Controllers\\AdminController::updateOrderStatus() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\n\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1.\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["9cf07fc703009bc41d2d6794677c2465"],"testsCompleted":3},{"id":"6dc8c3f5d3b671f7634d36f50609a72c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":322,"column":13},"end":{"line":322,"column":37}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2760 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":[],"testsCompleted":0},{"id":"e050f75ab2395d7d30981e38b612839b","mutatorName":"PublicVisibility","replacement":"protected function deleteOrder($orderId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":333,"column":5},"end":{"line":333,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 548 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder\nError: Call to protected method Controllers\\AdminController::deleteOrder() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:141\n\nERRORS!\r\nTests: 6, Assertions: 16, Errors: 1.\r\n","coveredBy":["9f4d645aba7ebec46f8fa49817ad0027"],"killedBy":["9f4d645aba7ebec46f8fa49817ad0027"],"testsCompleted":6},{"id":"e3b5d39310131d3a7592b75add0b944b","mutatorName":"PublicVisibility","replacement":"protected function getAllUsers()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":346,"column":5},"end":{"line":346,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nError: Call to protected method Controllers\\AdminController::getAllUsers() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:108\n\nERRORS!\r\nTests: 4, Assertions: 8, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"6e9809e6e1b77c8140569b746681c58d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":349,"column":13},"end":{"line":349,"column":30}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"a3e8092798c68661fe7534b918aa697c","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":352,"column":13},"end":{"line":359,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nFailed asserting that actual size 0 matches expected size 2.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:111\n\nFAILURES!\r\nTests: 4, Assertions: 10, Failures: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"744ab5f04eb8c1c3d67a1e754319238d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":354,"column":17},"end":{"line":354,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"abfd35562c03753103bcdf0c1eeb641f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":356,"column":17},"end":{"line":356,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nFailed asserting that null matches expected 'user@test.com'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\n\nFAILURES!\r\nTests: 4, Assertions: 14, Failures: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"1ee1be5faf40e325151fd7cbf435ce29","mutatorName":"PublicVisibility","replacement":"protected function deleteUser($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":367,"column":5},"end":{"line":367,"column":42}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 613 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\nError: Call to protected method Controllers\\AdminController::deleteUser() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\n\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1.\r\n","coveredBy":["cff255228f49b624005b9e8e6a3187d2"],"killedBy":["cff255228f49b624005b9e8e6a3187d2"],"testsCompleted":7},{"id":"5131e3f7115f35f9b0d61324417f7247","mutatorName":"PublicVisibility","replacement":"protected function getAllMessages()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":380,"column":5},"end":{"line":380,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nError: Call to protected method Controllers\\AdminController::getAllMessages() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:176\n\nERRORS!\r\nTests: 8, Assertions: 18, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"9399cb7c2b8f8ac70eefff98399ddc76","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":384,"column":13},"end":{"line":393,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 686 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nFailed asserting that actual size 0 matches expected size 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:179\n\nFAILURES!\r\nTests: 8, Assertions: 20, Failures: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"272fd2648322815f1331dad0dca8c592","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":386,"column":17},"end":{"line":386,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2765 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.058, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":[],"testsCompleted":0},{"id":"c177d07339aa7ff618cc10e640ca629f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":387,"column":17},"end":{"line":387,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":[],"testsCompleted":0},{"id":"62eb53c4f3ab10af6c9636d96c0c9eef","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":388,"column":17},"end":{"line":388,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nFailed asserting that null matches expected 'Test message'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:180\n\nFAILURES!\r\nTests: 8, Assertions: 21, Failures: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"40189c8485400b64ecd6c9fbd5f06230","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":390,"column":17},"end":{"line":390,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 683 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\nFailed asserting that null matches expected 'test@test.com'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:181\n\nFAILURES!\r\nTests: 8, Assertions: 22, Failures: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1"],"killedBy":["36243924380b2e3a203435fb9bdce1d1"],"testsCompleted":8},{"id":"d44b33d3e05dfd578237dbb3bc4254ae","mutatorName":"PublicVisibility","replacement":"protected function deleteMessage($messageId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":401,"column":5},"end":{"line":401,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 754 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage\nError: Call to protected method Controllers\\AdminController::deleteMessage() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:192\n\nERRORS!\r\nTests: 9, Assertions: 22, Errors: 1.\r\n","coveredBy":["111d21c767467e138a3e41568fbcceab"],"killedBy":["111d21c767467e138a3e41568fbcceab"],"testsCompleted":9}]},"Controllers\/ContactController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\r\n protected function createUser()\r\n {\r\n return new User();\r\n }\r\n\r\n protected function createMessage()\r\n {\r\n return new Message();\r\n }\r\n\r\n public function sendMessage($userData) {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n if (!isset($userData['user_id']) || !isset($userData['name']) || \r\n !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n if (!$user->exists($this->conn)) {\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }\r\n\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);\r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);\r\n $message->setMessage($userData['message']);\r\n\r\n if ($message->exists($this->conn)) { \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n}","mutants":[{"id":"d1d77da730c645e71c3a16d2dcde0691","mutatorName":"ProtectedVisibility","replacement":"private function createUser()","description":"Replaces the `protected` method visibility keyword with `private`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","5aeab43d6bb5e254f77e2aa5dac28edb"],"killedBy":[],"testsCompleted":0},{"id":"326bc1e50b62ca752229c3b73569a08d","mutatorName":"NewObject","replacement":"new User();\r\n return null;","description":"Replaces a newly instantiated object with `null` instead. The instantiation statement is kept in order\nto preserve potential side effects. Example:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n return new stdClass();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n new stdClass();\n return null;\n }\n}\n```\n","location":{"start":{"line":19,"column":9},"end":{"line":19,"column":27}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","5aeab43d6bb5e254f77e2aa5dac28edb"],"killedBy":[],"testsCompleted":0},{"id":"44ffffcf3fb0767550593ddcb4affb87","mutatorName":"ProtectedVisibility","replacement":"private function createMessage()","description":"Replaces the `protected` method visibility keyword with `private`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\nPHPUnit\\Framework\\MockObject\\MethodCannotBeConfiguredException: Trying to configure method \"createMessage\" which cannot be configured because it does not exist, has not been specified, is final, or is static\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:35\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["68e73fbb4670258440901c3a46e2064d"],"killedBy":["9ebb033692c3de0faab3cd111369f928"],"testsCompleted":1},{"id":"21f1ad6be65ee07e4f3d4fe00b5b7aea","mutatorName":"NewObject","replacement":"new Message();\r\n return null;","description":"Replaces a newly instantiated object with `null` instead. The instantiation statement is kept in order\nto preserve potential side effects. Example:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n return new stdClass();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo(): ?stdClass\n {\n new stdClass();\n return null;\n }\n}\n```\n","location":{"start":{"line":24,"column":9},"end":{"line":24,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......F\nNotice: fwrite(): Write of 826 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message\nFailed asserting that null is an instance of class \"Models\\Message\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:179\n\nFAILURES!\r\nTests: 8, Assertions: 14, Failures: 1.\r\n","coveredBy":["68e73fbb4670258440901c3a46e2064d"],"killedBy":["68e73fbb4670258440901c3a46e2064d"],"testsCompleted":8},{"id":"daf84e3955ef93066d1ce3fe135ed3c0","mutatorName":"PublicVisibility","replacement":"protected function sendMessage($userData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":27,"column":5},"end":{"line":27,"column":45}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"fe9367649c15baba6cef2eb4f993450b","mutatorName":"LogicalNot","replacement":"if (isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":30,"column":13},"end":{"line":30,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"aff65a440abf1765cf633f3eebc9cc36","mutatorName":"LogicalNot","replacement":"if (!isset($userData['user_id']) || isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":30,"column":13},"end":{"line":30,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"efaf2ddd305b7582882d60dd2ade8933","mutatorName":"LogicalOr","replacement":"if (!isset($userData['user_id']) && !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":30,"column":13},"end":{"line":30,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"ffe4471c5d89a51096037026d8c36449","mutatorName":"LogicalOr","replacement":"if ((!isset($userData['user_id']) || !isset($userData['name'])) && !isset($userData['email']) || !isset($userData['message'])) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":30,"column":13},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"9ead9cb3e6961d2c1bf2208f5d7fdc46","mutatorName":"LogicalOr","replacement":"if ((!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email'])) && !isset($userData['message'])) {","description":"Replaces an OR operator (`||`) with an AND operator (`&&`).","location":{"start":{"line":30,"column":13},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"da9e5951fd499b5eb9f525f1e16d12af","mutatorName":"LogicalNot","replacement":"if (!isset($userData['user_id']) || !isset($userData['name']) || isset($userData['email']) || !isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":31,"column":17},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"3a900415d5f02c6ea10eed7d70d7a563","mutatorName":"LogicalNot","replacement":"if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || isset($userData['message'])) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":31,"column":17},"end":{"line":31,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","b488b34d4881115bec02ef8105e30716","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","b93f5bfed89d4ed88cd4c8765ceac045","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"9a17629d6b94998b3d033c3f6c4c5b57","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Faltan campos requeridos'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":32,"column":17},"end":{"line":32,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["b488b34d4881115bec02ef8105e30716","b93f5bfed89d4ed88cd4c8765ceac045"],"killedBy":[],"testsCompleted":0},{"id":"3b92aac6e83e59d8f7769ce5c7cdf46a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Faltan campos requeridos'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":32,"column":17},"end":{"line":32,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["b488b34d4881115bec02ef8105e30716","b93f5bfed89d4ed88cd4c8765ceac045"],"killedBy":[],"testsCompleted":0},{"id":"797a8daa33090c10af0799f82262849d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":37,"column":13},"end":{"line":37,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"9029cff1b16e62a3c708a72fe5952461","mutatorName":"LogicalNot","replacement":"if ($user->exists($this->conn)) {","description":"Removes a negation operator (`!`), e.g. transforms `!$foo` with `$foo`.","location":{"start":{"line":38,"column":13},"end":{"line":38,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e","966624d19ce2dba3bed3eccf1c0f956f","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":[],"testsCompleted":0},{"id":"5d63f0a7753a559e19ac2b2c291fba6a","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Usuario no encontrado'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":39,"column":17},"end":{"line":39,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","966624d19ce2dba3bed3eccf1c0f956f"],"killedBy":[],"testsCompleted":0},{"id":"1d789e09cb9505b1f5125712fb5bd8ad","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Usuario no encontrado'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":39,"column":17},"end":{"line":39,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","966624d19ce2dba3bed3eccf1c0f956f"],"killedBy":[],"testsCompleted":0},{"id":"fad512c004d3d0e04c1a3d3e55cd30e6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":43,"column":13},"end":{"line":43,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setUserId\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"b0877614aadd4b9ffc10ae048f0f8b2e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":44,"column":13},"end":{"line":44,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setName\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"10e991df75b8d67dbd89c144af94637d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":45,"column":13},"end":{"line":45,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setEmail\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"946c2fbb735321cb9ee7cec323f0a413","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":46,"column":13},"end":{"line":46,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setNumber\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"9d4927fa3ed94d06f8383de4669352b3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":47,"column":13},"end":{"line":47,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\nExpectation failed for method name is \"setMessage\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","dadb1321b7b0db79872fdfdbe6115493","1a5c37673a34ba1e37ac2923b430a4e6","c7648c8a27ed50c48a0d2328c2890535","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["aa989a99b189876d061fe9ba83f42bce"],"testsCompleted":9},{"id":"16a349d69a6eec1a153da7a7536e25cf","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => '\u00a1Mensaje ya enviado!'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":50,"column":17},"end":{"line":50,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 451 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\n\nFAILURES!\r\nTests: 4, Assertions: 7, Failures: 1.\r\n","coveredBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"killedBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"testsCompleted":4},{"id":"112d6201db25ea7829e0b0236dec23c4","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Mensaje ya enviado!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":50,"column":17},"end":{"line":50,"column":83}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 452 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\n\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1.\r\n","coveredBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"killedBy":["1a5c37673a34ba1e37ac2923b430a4e6"],"testsCompleted":4},{"id":"e62f4e3af08d6d884c1194aaada59089","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Mensaje enviado exitosamente!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":92}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["9ebb033692c3de0faab3cd111369f928"],"testsCompleted":1},{"id":"3aeb4804ec19a9853b58e2c748922f4a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Mensaje enviado exitosamente!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":92}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["d59917b2d5528ca6063952ee4f1d097b","aa989a99b189876d061fe9ba83f42bce","9ebb033692c3de0faab3cd111369f928"],"killedBy":["9ebb033692c3de0faab3cd111369f928"],"testsCompleted":1},{"id":"996a72cab07496167c42526ee1bd7f87","mutatorName":"Concat","replacement":"error_log($userData['user_id'] . \"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"e3134f59e642cba1cfa2f45c7755ffc2","mutatorName":"ConcatOperandRemoval","replacement":"error_log($userData['user_id']);","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"29deadb639a0292036d21dcb170c84bb","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"5053d4fa5a03673c7191c1386e99b466","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":113}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":[],"testsCompleted":0},{"id":"f04179551a36e95ab710990fef6ce8b7","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al enviar mensaje'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":81}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 542 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\n\nFAILURES!\r\nTests: 5, Assertions: 9, Failures: 1.\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":["dadb1321b7b0db79872fdfdbe6115493"],"testsCompleted":5},{"id":"febbfc1aaa19c48addc652b10d4dcec5","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al enviar mensaje'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":81}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\n\nERRORS!\r\nTests: 5, Assertions: 8, Errors: 1.\r\n","coveredBy":["dadb1321b7b0db79872fdfdbe6115493"],"killedBy":["dadb1321b7b0db79872fdfdbe6115493"],"testsCompleted":5},{"id":"f9f89dfb155a35bb5b580c77ae656af4","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al enviar mensaje: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"dd145de5420bd7526e9840e9c18fb0ec","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"a4894786dc78c58bcf56951a62b940c6","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al enviar mensaje: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"eccdfbbcafc132dc0eaf227f3f65e9ad","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":61,"column":13},"end":{"line":61,"column":71}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"e359f075d04152f5f530d91442aba870","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\n\nFAILURES!\r\nTests: 6, Assertions: 11, Failures: 1.\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":["76926558c21488fe35e209f0ecda409e"],"testsCompleted":6},{"id":"c3640ffbbccb8d607cb1c4b722c0b7cf","mutatorName":"Concat","replacement":"return ['success' => false, 'message' => $e->getMessage() . 'Error al enviar mensaje: '];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"9a1e00bbfa63587641ab92cc67698e91","mutatorName":"ConcatOperandRemoval","replacement":"return ['success' => false, 'message' => $e->getMessage()];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\nFailed asserting that 'Error de conexi\u00f3n' contains \"Error al enviar mensaje\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:153\n\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1.\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":["76926558c21488fe35e209f0ecda409e"],"testsCompleted":6},{"id":"59ba8d3ad85054d62810c011d429b78b","mutatorName":"ConcatOperandRemoval","replacement":"return ['success' => false, 'message' => 'Error al enviar mensaje: '];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n............ 12 \/ 12 (100%)\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":[],"testsCompleted":0},{"id":"dac6a1694673b01ca662f87eb508ecf2","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al enviar mensaje: ' . $e->getMessage()];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":102}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\n\nERRORS!\r\nTests: 6, Assertions: 10, Errors: 1.\r\n","coveredBy":["c7648c8a27ed50c48a0d2328c2890535","76926558c21488fe35e209f0ecda409e"],"killedBy":["76926558c21488fe35e209f0ecda409e"],"testsCompleted":6}]},"Controllers\/OrderController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function getOrders($userId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function updatePaymentStatus($orderId, $status) {\r\n try {\r\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$status, $orderId]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function deleteOrder($orderId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\r\n return $stmt->execute([$orderId]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function getAllOrders() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function createOrder($userData, $userId) {\r\n try {\r\n $order = new Order();\r\n $order->setUserId($userId);\r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);\r\n $order->setMethod($userData['method']);\r\n \r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if(empty($cartItems)) {\r\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n\r\n \/\/ Validar productos antes de procesar\r\n foreach($cartItems as $item) {\r\n if(empty($item['name'])) {\r\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n }\r\n if($item['price'] < 0) {\r\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\r\n }\r\n }\r\n\r\n \/\/ Calcular total y preparar lista de productos\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n $cartTotal += ($item['price'] * $item['quantity']);\r\n }\r\n $totalProducts = implode(', ', $products);\r\n\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n $address = 'flat no. ' . $userData['flat'] . ', ' . \r\n $userData['street'] . ', ' . \r\n $userData['city'] . ', ' . \r\n $userData['country'] . ' - ' . \r\n $userData['pin_code'];\r\n \r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);\r\n $order->setTotalPrice($cartTotal);\r\n \r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?\");\r\n \r\n $stmt->execute([\r\n $order->getName(),\r\n $order->getNumber(),\r\n $order->getEmail(),\r\n $order->getMethod(),\r\n $order->getAddress(),\r\n $order->getTotalProducts(),\r\n $order->getTotalPrice()\r\n ]);\r\n\r\n if($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \r\n (user_id, name, number, email, method, address, \r\n total_products, total_price, placed_on) \r\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n\r\n $stmt->execute([\r\n $order->getUserId(),\r\n $order->getName(),\r\n $order->getNumber(),\r\n $order->getEmail(),\r\n $order->getMethod(),\r\n $order->getAddress(),\r\n $order->getTotalProducts(),\r\n $order->getTotalPrice(),\r\n date('d-M-Y')\r\n ]);\r\n\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }\r\n\r\n private function getCartItems($userId) {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n }\r\n\r\n private function clearCart($userId) {\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n }\r\n\r\n public function getUserOrders($userId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n $orders = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $orders[] = $order;\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function getAllProducts() {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n public function getAllUsers() {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }\r\n return $users;\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);\r\n return [];\r\n }\r\n }\r\n\r\n private function handleDatabaseError(\\Exception $e) {\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n }\r\n} ","mutants":[{"id":"b011449c4da94522d894f44b4e35c8d2","mutatorName":"PublicVisibility","replacement":"protected function getOrders($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.......E\nNotice: fwrite(): Write of 778 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos\nError: Call to protected method Controllers\\OrderController::getOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:231\n\nERRORS!\r\nTests: 8, Assertions: 28, Errors: 1.\r\n","coveredBy":["ceb6936c11cf19bb44e528fa327f0416"],"killedBy":["ceb6936c11cf19bb44e528fa327f0416"],"testsCompleted":8},{"id":"3c3303dfaec40c4c283864648498c68d","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":40,"column":13},"end":{"line":40,"column":44}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["ceb6936c11cf19bb44e528fa327f0416"],"killedBy":[],"testsCompleted":0},{"id":"376fe58a9944ac94091c137db0669cc3","mutatorName":"PublicVisibility","replacement":"protected function updatePaymentStatus($orderId, $status)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":45,"column":5},"end":{"line":45,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["ac9ac5f42f33e350edbcf6e51247ed95","40ff0078972e38dca8cfb4be5e49a3b0"],"killedBy":[],"testsCompleted":0},{"id":"18790cd45a04fd179430da33248c85d6","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([$orderId]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":48,"column":13},"end":{"line":48,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["ac9ac5f42f33e350edbcf6e51247ed95","40ff0078972e38dca8cfb4be5e49a3b0"],"killedBy":[],"testsCompleted":0},{"id":"04c5eb4b77676b6be0e9be886b2e4afe","mutatorName":"PublicVisibility","replacement":"protected function deleteOrder($orderId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":55,"column":5},"end":{"line":55,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["9112c9fc2d730bc2c02af9b6785500ea","452ca6af2bdb570f2ff036e996e62a49"],"killedBy":[],"testsCompleted":0},{"id":"2a04db4fe40e9e3fe5fd61c379172419","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":58,"column":13},"end":{"line":58,"column":47}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["9112c9fc2d730bc2c02af9b6785500ea","452ca6af2bdb570f2ff036e996e62a49"],"killedBy":[],"testsCompleted":0},{"id":"ea0713e667ff03d193c73d4fdaa741cf","mutatorName":"PublicVisibility","replacement":"protected function getAllOrders()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":65,"column":5},"end":{"line":65,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 568 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nError: Call to protected method Controllers\\OrderController::getAllOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:195\n\nERRORS!\r\nTests: 6, Assertions: 19, Errors: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":6},{"id":"2a3e272b05aa6680a03345b0eadec829","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":68,"column":13},"end":{"line":68,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 572 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 6, Assertions: 24, Failures: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":6},{"id":"6186dc3d07fdef24bdd14d2445f69f5b","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":70,"column":13},"end":{"line":80,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 568 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:197\n\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":6},{"id":"f83a7bf6248093c49ef34b67456d9add","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":72,"column":17},"end":{"line":72,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 568 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\nFailed asserting that null is identical to 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:199\n\nFAILURES!\r\nTests: 6, Assertions: 22, Failures: 1.\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":["b989a99ca1b325941722866a40278e06"],"testsCompleted":6},{"id":"2ecbba998eb69367aebd9e2c4997f326","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":73,"column":17},"end":{"line":73,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"63339aaba74d3bc63b63ffee7e53047f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":74,"column":17},"end":{"line":74,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"9c7783eb0fec9f1683e73d4e2eded606","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":75,"column":17},"end":{"line":75,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"4ec6c815dbb9e143be7f84e78336281e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":76,"column":17},"end":{"line":76,"column":53}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1707 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"d146853ec7b77a224aea23a78966ac5c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":77,"column":17},"end":{"line":77,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1707 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"00a895b8ce075e2190d79f4040c55e3b","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":78,"column":17},"end":{"line":78,"column":60}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["b989a99ca1b325941722866a40278e06"],"killedBy":[],"testsCompleted":0},{"id":"f7cc093e80709a42e526f6d03e80404e","mutatorName":"PublicVisibility","replacement":"protected function createOrder($userData, $userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":88,"column":5},"end":{"line":88,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"9b3756eeebb9217633a87d62b08f971a","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":91,"column":13},"end":{"line":91,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"b1dacc82b0366d563fbe3f65804bf044","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":92,"column":13},"end":{"line":92,"column":48}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"c81b57cc7b850c3940a9fc157136690f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":93,"column":13},"end":{"line":93,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"768c3265ca65df234b6e9301f84a0df8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"7456245cd85c1dc349fc90f55b09a1b5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":95,"column":13},"end":{"line":95,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"a39fb0a67987198b60c48fcfbc265687","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El carrito est\u00e1 vac\u00edo'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":100,"column":17},"end":{"line":100,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","9b1d437f68a23ef8f0c60f232232f51c"],"killedBy":[],"testsCompleted":0},{"id":"41e93e1ea4ea74c3ee38e530fdd2cb2d","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El carrito est\u00e1 vac\u00edo'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":100,"column":17},"end":{"line":100,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","9b1d437f68a23ef8f0c60f232232f51c"],"killedBy":[],"testsCompleted":0},{"id":"56b279180119938bbf8bce0e4d565883","mutatorName":"Foreach_","replacement":"foreach (array() as $item) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":104,"column":13},"end":{"line":111,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..................F\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_total_negativo\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Error: precio inv\u00e1lido'\n+'Error al procesar el pedido'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:582\n\nFAILURES!\r\nTests: 19, Assertions: 79, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["8c41a583e9cacc1339195d554f197282"],"testsCompleted":19},{"id":"750a53996cfb24d2ff11def12a7361ec","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error: nombre de producto inv\u00e1lido'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":106,"column":21},"end":{"line":106,"column":101}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...................F 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1792 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_vacio\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:619\n\nFAILURES!\r\nTests: 20, Assertions: 82, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["ff1bda593a2fd4adf80246ca9ba4dfad"],"testsCompleted":20},{"id":"2601e73d69fac39a61ace133be574e92","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error: nombre de producto inv\u00e1lido'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":106,"column":21},"end":{"line":106,"column":101}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...................E 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1788 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_vacio\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:619\n\nERRORS!\r\nTests: 20, Assertions: 81, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["ff1bda593a2fd4adf80246ca9ba4dfad"],"testsCompleted":20},{"id":"df6335ca827747de646148e50e7f02fa","mutatorName":"LessThan","replacement":"if ($item['price'] <= 0) {","description":"Replaces a less-than operator (`<`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":108,"column":17},"end":{"line":108,"column":41}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"c2a6fc67a1b1bea831c915562a764e99","mutatorName":"LessThanNegotiation","replacement":"if ($item['price'] >= 0) {","description":"Replaces a less-than operator (`<`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":108,"column":17},"end":{"line":108,"column":41}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"e47304f9fe1fadea6aa5ad4d0fd51eba","mutatorName":"DecrementInteger","replacement":"$cartTotal = -1;","description":"Decrements an integer value with 1.","location":{"start":{"line":114,"column":13},"end":{"line":114,"column":28}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"7ef42c74b63ce105b6b198d98687a532","mutatorName":"Foreach_","replacement":"foreach (array() as $item) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":116,"column":13},"end":{"line":119,"column":43}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"a9b66b76e0a7a865cc1efca4beb8e03d","mutatorName":"Concat","replacement":"$products[] = ' (' . $item['name'] . $item['quantity'] . ')';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1707 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"5789e121a06e4d5fedf10d745e71e2d7","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = ' (' . $item['quantity'] . ')';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"0dab23e15a55d41ecb06240dc6e9545a","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = $item['name'] . $item['quantity'] . ')';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"45c3c783fe3396b6a193db878a9c85bf","mutatorName":"Concat","replacement":"$products[] = $item['name'] . $item['quantity'] . ' (' . ')';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"587a0ff74f2ad79abc7c335973f614f0","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = $item['name'] . ' (' . ')';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"3054ddbf515532c7661b038a7ad75801","mutatorName":"Concat","replacement":"$products[] = $item['name'] . ' (' . ')' . $item['quantity'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"c864cabdb0703f0e1ef8c6cd2b2e1048","mutatorName":"ConcatOperandRemoval","replacement":"$products[] = $item['name'] . ' (' . $item['quantity'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":117,"column":17},"end":{"line":117,"column":78}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"014afb4eb23d93a60014b22dc2092e04","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":123,"column":13},"end":{"line":125,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"23ab4f7b617dfe6c76e2b701e2f8b323","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":123,"column":13},"end":{"line":125,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1698 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"01b701c8cf91c328c75361e56806d8a3","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":123,"column":13},"end":{"line":125,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"4962599c72611682dacef710a38ecc8a","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":123,"column":13},"end":{"line":125,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"e2e3f979164917b04b27e3e6f52e4555","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":123,"column":13},"end":{"line":126,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"0c6ca2396fad60d7a951d07c41ce2927","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":123,"column":13},"end":{"line":126,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"de49e6702ccd0a1f3b7ff2e68a05090e","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code'];","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":123,"column":13},"end":{"line":126,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"5ba289cd3238eaf0d0980c247ec04282","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'];","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":123,"column":13},"end":{"line":126,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"34ad6b96b2da9de88d5ea41434121b46","mutatorName":"Concat","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - ';","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":123,"column":13},"end":{"line":127,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"df34d7f3d16e50e418a913f67bfa4677","mutatorName":"ConcatOperandRemoval","replacement":"$address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ';","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":123,"column":13},"end":{"line":127,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"bb93451ae25996782d9ec8c73f984d67","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":42}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"31f3cabc7b78eb576c7fb7a9f7dd6ddd","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":131,"column":13},"end":{"line":131,"column":54}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"e6999ef887eacfff4bdea3e3a9b4150f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":132,"column":13},"end":{"line":132,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"738a5bf7813e7c1d82f2f3c01d927b78","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":140,"column":13},"end":{"line":148,"column":29}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1711 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"03b3be09518bedae6cec8c8f534d876e","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":140,"column":13},"end":{"line":148,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"9907ef2afe466e31b8cc1884d1d38ef8","mutatorName":"GreaterThan","replacement":"if ($stmt->rowCount() >= 0) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":150,"column":13},"end":{"line":150,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 166 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"835c2d0eade613e0db4a64e68c8944e7","mutatorName":"GreaterThanNegotiation","replacement":"if ($stmt->rowCount() <= 0) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":150,"column":13},"end":{"line":150,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"6d13fdc95c919b62d70ccd62734f8465","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => '\u00a1Pedido ya realizado!'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":151,"column":17},"end":{"line":151,"column":84}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 1070 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:381\n\nFAILURES!\r\nTests: 12, Assertions: 45, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["d274c529f48ebd0c0d2e7e82410e3415"],"testsCompleted":12},{"id":"87b36cffd1e45ddb2366b9a58f77dc7a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Pedido ya realizado!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":151,"column":17},"end":{"line":151,"column":84}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........E\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:381\n\nERRORS!\r\nTests: 12, Assertions: 44, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09"],"killedBy":["d274c529f48ebd0c0d2e7e82410e3415"],"testsCompleted":12},{"id":"4f1ecc74297088d2c92c8455350ee65a","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":160,"column":13},"end":{"line":170,"column":29}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"895ffa639e1b075e9564f02ce4f8f984","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":160,"column":13},"end":{"line":170,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"18b6b3971dd694d8b8ca7175bd91b6fd","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":173,"column":13},"end":{"line":173,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"956ca3e9ca75f5d23a8285e2b53424d0","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":175,"column":13},"end":{"line":175,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"457daf2ce9cbeabf66a6c027d91b5581","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Pedido realizado con \u00e9xito!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":175,"column":13},"end":{"line":175,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":[],"testsCompleted":0},{"id":"7dfabb57ee09ad57feeeb4124ed8fa76","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":190,"column":9},"end":{"line":190,"column":35}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1715 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"99887ad51171f98c9aa97b5413908846","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":190,"column":9},"end":{"line":190,"column":35}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\nMethod was expected to be called 4 times, actually called 3 times.\n\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"d6111c43242e6077abdd97e1575f5369","mutatorName":"PublicVisibility","replacement":"protected function getUserOrders($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":193,"column":5},"end":{"line":193,"column":45}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nError: Call to protected method Controllers\\OrderController::getUserOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\n\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"5b1d13e222b7e4b94151ebf318fd001a","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":196,"column":13},"end":{"line":196,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\n\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"9e41122daea09a65ff6188eb40e60e50","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":196,"column":13},"end":{"line":196,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"4e67183ccf9337cb69c92f92cca79144","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":198,"column":13},"end":{"line":211,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\n\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940","116e55b7e31c4b7eb431eadb6fd89108","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"3208341fc38ca665d929f3bd1908ee48","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":200,"column":17},"end":{"line":200,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nFailed asserting that null is identical to 1.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:104\n\nFAILURES!\r\nTests: 2, Assertions: 7, Failures: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"f6b01089076bb25cac0481bf1c03c996","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":202,"column":17},"end":{"line":202,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":[],"testsCompleted":0},{"id":"6b1bf93b082050becebd26a8a08f7562","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener \u00f3rdenes del usuario: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":214,"column":13},"end":{"line":214,"column":85}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":[],"testsCompleted":0},{"id":"59d080dee7ef28f157664666b21eaa5c","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":214,"column":13},"end":{"line":214,"column":85}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":[],"testsCompleted":0},{"id":"599026acf82d22382c23da67d0f939a7","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener \u00f3rdenes del usuario: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":214,"column":13},"end":{"line":214,"column":85}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1711 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":[],"testsCompleted":0},{"id":"ee8fa0db0e06d6e1a87e5e891bea6dae","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":214,"column":13},"end":{"line":214,"column":85}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["0dbb68598d76d4d127b823247b0e445a"],"killedBy":[],"testsCompleted":0},{"id":"b3e25abf3eac4f8aeb5622048590cbc3","mutatorName":"PublicVisibility","replacement":"protected function getAllProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":219,"column":5},"end":{"line":219,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 841 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Controllers\\OrderController::getAllProducts() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\n\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1.\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":9},{"id":"b201405fa0a9c6a8d0a0a2525e2d97df","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":223,"column":13},"end":{"line":229,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F\nNotice: fwrite(): Write of 840 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:274\n\nFAILURES!\r\nTests: 9, Assertions: 31, Failures: 1.\r\n","coveredBy":["116e55b7e31c4b7eb431eadb6fd89108","b388534ee189eeb5ea1ebdd33ff1fb04","aca810d1d7530667d800dd6115dd2020"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":9},{"id":"d894fd8ef3d26b0a324bc32443b19ad2","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":232,"column":13},"end":{"line":232,"column":44}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.................... 20 \/ 20 (100%)\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)\r\n","coveredBy":["aca810d1d7530667d800dd6115dd2020"],"killedBy":[],"testsCompleted":0},{"id":"2f939ed8e806ca34088375adfe865ca1","mutatorName":"PublicVisibility","replacement":"protected function getAllUsers()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":237,"column":5},"end":{"line":237,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Controllers\\OrderController::getAllUsers() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\n\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1.\r\n","coveredBy":["b388534ee189eeb5ea1ebdd33ff1fb04","aca810d1d7530667d800dd6115dd2020"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10},{"id":"12bbc48fdc8e3b7b4ec49b3be901487f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":240,"column":13},"end":{"line":240,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 914 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 10, Assertions: 40, Failures: 1.\r\n","coveredBy":["b388534ee189eeb5ea1ebdd33ff1fb04"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10},{"id":"68135ab67a037e6f46294b0c986736f1","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":242,"column":13},"end":{"line":248,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........F\nNotice: fwrite(): Write of 913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nFailed asserting that an array is not empty.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:308\n\nFAILURES!\r\nTests: 10, Assertions: 36, Failures: 1.\r\n","coveredBy":["b388534ee189eeb5ea1ebdd33ff1fb04","116e55b7e31c4b7eb431eadb6fd89108","ceb6936c11cf19bb44e528fa327f0416"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10}]},"Controllers\/ProductController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function getLatestProducts($limit = 6) {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n $stmt->execute();\r\n \r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function addToCart($userId, $productData) {\r\n try {\r\n $cart = new Cart();\r\n $cart->setUserId($userId);\r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);\r\n $cart->setImage($productData['product_image']);\r\n \r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n \r\n if($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \r\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n \r\n $stmt->execute([\r\n $cart->getUserId(),\r\n $cart->getName(),\r\n $cart->getPrice(),\r\n $cart->getQuantity(),\r\n $cart->getImage()\r\n ]);\r\n \r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n\r\n public function getAllProducts() {\r\n try {\r\n $query = \"SELECT * FROM products\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n \r\n $products = [];\r\n foreach($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function getCartItems($userId) {\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n\r\n public function updateCartQuantity($cartId, $quantity) {\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n\r\n public function deleteCartItem($cartId) {\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n\r\n public function deleteAllCartItems($userId) {\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n return false;\r\n }\r\n }\r\n} ","mutants":[{"id":"d6d54c88f7e7bcc700e5cd534289a119","mutatorName":"DecrementInteger","replacement":"public function getLatestProducts($limit = 5)","description":"Decrements an integer value with 1.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"cb5dee4206891e8397f80d3523a45f24","mutatorName":"IncrementInteger","replacement":"public function getLatestProducts($limit = 7)","description":"Increments an integer value with 1.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":52}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"b615375a11c75009f00873c01cc9f5b1","mutatorName":"PublicVisibility","replacement":"protected function getLatestProducts($limit = 6)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nError: Call to protected method Controllers\\ProductController::getLatestProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"ac4b4ea16d5de524f7a4bf1614986fa5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":21,"column":13},"end":{"line":21,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"b0af52ebc8a3f8416a7d37b354590da3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":22,"column":13},"end":{"line":22,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 1, Assertions: 5, Failures: 1.\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"c18f40733296721d67a46880fb59a2ee","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":25,"column":13},"end":{"line":32,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nUndefined array key 0\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:50\n\nERRORS!\r\nTests: 1, Assertions: 1, Errors: 1.\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"e6a75da202b4d89d6bf89556680a9352","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":27,"column":17},"end":{"line":27,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"f5a1cd95d103243b4c469def77fb7ae3","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":28,"column":17},"end":{"line":28,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 200 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nFailed asserting that null is identical to 'Producto Test'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:51\n\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1.\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1},{"id":"26097a10bfeb515bb1d953b542b0b8fa","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":29,"column":17},"end":{"line":29,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"8898976f42919a768ac513dab7a4f6e6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":30,"column":17},"end":{"line":30,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":[],"testsCompleted":0},{"id":"4d1ac6ed6893512957b4a9153e3cc6ee","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener productos: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"00ccebca1662d6819abe405d8dd9b480","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"8fcaf7ff70998a616d1aecac111045dc","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener productos: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"ad8cc5770c1b7e73b23769d969d399b5","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":35,"column":13},"end":{"line":35,"column":74}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["feb6d707c4d8182bd8ec66df03f90917"],"killedBy":[],"testsCompleted":0},{"id":"b4b0e110d7b05163ec40be42238cdb37","mutatorName":"PublicVisibility","replacement":"protected function addToCart($userId, $productData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":40,"column":5},"end":{"line":40,"column":55}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"f4ec3b9d0c2842861563b5d1e97da9af","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":43,"column":13},"end":{"line":43,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"4138a8579f71e8f7077aa1ca4ac61b94","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":44,"column":13},"end":{"line":44,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"261655f88d0d4a2df1188efb1f6346a8","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":45,"column":13},"end":{"line":45,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"d915a71b9d8b30c4e4b3bd7bc9f23e5c","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":46,"column":13},"end":{"line":46,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"702272c32699bb6eee6e6d986f324598","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":47,"column":13},"end":{"line":47,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"35cde21cf32f8acf0639e13745ea86d3","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$cart->getName()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"602d7a228dd6751acaf07bc3019f4c07","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"a96b3e0e62d4a49204880299299d405f","mutatorName":"GreaterThan","replacement":"if ($stmt->rowCount() >= 0) {","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":53,"column":13},"end":{"line":53,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"3e64aaf89dd58733dfc34969de895b62","mutatorName":"GreaterThanNegotiation","replacement":"if ($stmt->rowCount() <= 0) {","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":53,"column":13},"end":{"line":53,"column":40}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"a6f90c4316b1b3e8012f4cf3d9e62308","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El producto ya est\u00e1 en el carrito'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":96}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679"],"killedBy":[],"testsCompleted":0},{"id":"47993b7535206b3af3a84b118f825835","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El producto ya est\u00e1 en el carrito'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":54,"column":17},"end":{"line":54,"column":96}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679"],"killedBy":[],"testsCompleted":0},{"id":"c0820143b0a2749619aac748e835a8f9","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":62,"column":13},"end":{"line":68,"column":29}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"9b2e52933a01b2b15d7edc2487d28ab9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":62,"column":13},"end":{"line":68,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nExpectation failed for method name is \"execute\" when invoked 2 time(s).\nMethod was expected to be called 2 times, actually called 1 times.\n\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"d6265aca1d58bf8aca33e7a568c47503","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => 'Producto a\u00f1adido al carrito'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 267 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\n\nFAILURES!\r\nTests: 2, Assertions: 6, Failures: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"e26136a2464024cee484dea4abe54d61","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Producto a\u00f1adido al carrito'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"c624c6d9e4ebf2d542fb852c9de594e6","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al a\u00f1adir al carrito: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1438 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"3006f81bfb344f8dbfc44721a7ea2e6e","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"3a8966d1e26e0ab9ac37d9ee03b4fcb8","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al a\u00f1adir al carrito: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"f5fd0ecc24849b48869aef26fbc453b2","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":75}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1466 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":[],"testsCompleted":0},{"id":"4688e1d0a80ef2d0f197c178e36fd694","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al a\u00f1adir al carrito'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............F\nNotice: fwrite(): Write of 1459 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\n\nFAILURES!\r\nTests: 15, Assertions: 49, Failures: 1.\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":["21b277a20d75495834b915634005099f"],"testsCompleted":15},{"id":"18f87be6894ef590a645091114401f5f","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al a\u00f1adir al carrito'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":85}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..............E\nNotice: fwrite(): Write of 1468 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\n\nERRORS!\r\nTests: 15, Assertions: 48, Errors: 1.\r\n","coveredBy":["21b277a20d75495834b915634005099f"],"killedBy":["21b277a20d75495834b915634005099f"],"testsCompleted":15},{"id":"b857672f3fe1351e5a657ef4a433a8ab","mutatorName":"PublicVisibility","replacement":"protected function getAllProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":77,"column":5},"end":{"line":77,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nError: Call to protected method Controllers\\ProductController::getAllProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:200\n\nERRORS!\r\nTests: 7, Assertions: 22, Errors: 1.\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc","cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"0fb427f2d05aa2c6c9ea852f70e00675","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":81,"column":13},"end":{"line":81,"column":30}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 7, Assertions: 28, Failures: 1.\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"21073abf213dd6029c9e66371981903a","mutatorName":"Foreach_","replacement":"foreach (array() as $row) {","description":"Replaces the iterable being iterated over with a `foreach` statement with an empty array, preventing\nany statement within the block to be executed. For example:\n\n```php`\nforeach ($a as $b) {\n \/\/ ...\n}\n```\n\nWill be mutated to:\n\n```php\nfor ([] as $b]) {\n \/\/ ...\n}\n```","location":{"start":{"line":84,"column":13},"end":{"line":91,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nFailed asserting that actual size 0 matches expected size 2.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:202\n\nFAILURES!\r\nTests: 7, Assertions: 23, Failures: 1.\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"784f6a531ab3840f939ccef4f41214c0","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":86,"column":17},"end":{"line":86,"column":45}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":[],"testsCompleted":0},{"id":"1a85a8dcc3af9c193671670c138895d1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":87,"column":17},"end":{"line":87,"column":49}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\nFailed asserting that null matches expected 'Producto 1'.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:204\n\nFAILURES!\r\nTests: 7, Assertions: 25, Failures: 1.\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":["cb81a55cafc96c5e140058f48b76748b"],"testsCompleted":7},{"id":"ce565ed8cbc64274189c97a9cda902e7","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":88,"column":17},"end":{"line":88,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":[],"testsCompleted":0},{"id":"46e2cd6f0c9740e8bcdfa4f8cb0e96f1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":89,"column":17},"end":{"line":89,"column":51}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["cb81a55cafc96c5e140058f48b76748b"],"killedBy":[],"testsCompleted":0},{"id":"1e0894de8803af94aca4e3b90de9b785","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener todos los productos: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"710646a2223ead6b9521b321faf8b0e2","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"39a9bbe4f12cceb23d860a23f43a88f1","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener todos los productos: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"94f1c099842e4ed192f2e9301d9164ae","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":94,"column":13},"end":{"line":94,"column":84}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["96cb93ace2fec2f94dda2e1aac950bbc"],"killedBy":[],"testsCompleted":0},{"id":"694750d813a3bb2865a9d969a146a3e5","mutatorName":"PublicVisibility","replacement":"protected function getCartItems($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":99,"column":5},"end":{"line":99,"column":44}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\nError: Call to protected method Controllers\\ProductController::getCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:107\n\nERRORS!\r\nTests: 3, Assertions: 9, Errors: 1.\r\n","coveredBy":["5144a3795216d9768bcf2e1b0de52d7c","47942d6a996427c3c1cec9efff6173b2","242f299f525da768f9961477f538fcf7"],"killedBy":["242f299f525da768f9961477f538fcf7"],"testsCompleted":3},{"id":"ce41b6487e187b75a062456dfb751d5a","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":103,"column":13},"end":{"line":103,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\nFailed asserting that two arrays are identical.\n--- Expected\n+++ Actual\n@@ @@\n-Array &0 (\n- 0 => Array &1 (\n- 'id' => 1\n- 'name' => 'Producto Test'\n- 'price' => 99.99\n- 'quantity' => 1\n- 'image' => 'test.jpg'\n- )\n-)\n+Array &0 ()\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:109\n\nFAILURES!\r\nTests: 3, Assertions: 10, Failures: 1.\r\n","coveredBy":["5144a3795216d9768bcf2e1b0de52d7c","242f299f525da768f9961477f538fcf7"],"killedBy":["242f299f525da768f9961477f538fcf7"],"testsCompleted":3},{"id":"b2da999489995b0a16b3ace9301d5cf2","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":103,"column":13},"end":{"line":103,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 3, Assertions: 12, Failures: 1.\r\n","coveredBy":["5144a3795216d9768bcf2e1b0de52d7c","242f299f525da768f9961477f538fcf7"],"killedBy":["242f299f525da768f9961477f538fcf7"],"testsCompleted":3},{"id":"b4b7f29733608f93f0fc4ad249802726","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener items del carrito: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"5e629f922236b75f97ad9632cb4e2fa9","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"e586a8f894dc539830e72082dd891a41","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener items del carrito: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"e86a4649ebe026d7dbb9fe54acba6b0d","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":106,"column":13},"end":{"line":106,"column":82}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["47942d6a996427c3c1cec9efff6173b2"],"killedBy":[],"testsCompleted":0},{"id":"7182b103c5983d238b111c4ef2e734b0","mutatorName":"PublicVisibility","replacement":"protected function updateCartQuantity($cartId, $quantity)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":111,"column":5},"end":{"line":111,"column":61}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8","fc8f4ab810696c7119210820c8dcb994"],"killedBy":[],"testsCompleted":0},{"id":"acdcc7e8050848d4586886ade3091abc","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$cartId]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":115,"column":13},"end":{"line":115,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8","fc8f4ab810696c7119210820c8dcb994"],"killedBy":[],"testsCompleted":0},{"id":"91ee67d8640fd87862f0fb6d52f276ad","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":115,"column":13},"end":{"line":115,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8","fc8f4ab810696c7119210820c8dcb994"],"killedBy":[],"testsCompleted":0},{"id":"842df3cf1478df61d8fb3eb42d776391","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => '\u00a1Cantidad actualizada!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":116,"column":13},"end":{"line":116,"column":80}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\n\nFAILURES!\r\nTests: 4, Assertions: 13, Failures: 1.\r\n","coveredBy":["fc8f4ab810696c7119210820c8dcb994"],"killedBy":["fc8f4ab810696c7119210820c8dcb994"],"testsCompleted":4},{"id":"6eb4ca894e3a533334bbd3b28df406cc","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => '\u00a1Cantidad actualizada!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":116,"column":13},"end":{"line":116,"column":80}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\n\nERRORS!\r\nTests: 4, Assertions: 12, Errors: 1.\r\n","coveredBy":["fc8f4ab810696c7119210820c8dcb994"],"killedBy":["fc8f4ab810696c7119210820c8dcb994"],"testsCompleted":4},{"id":"39da2691214ce313b6ce6fbf4808b546","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al actualizar cantidad: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"b98195cc14bd1c717572b0958ee04293","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"33d6a8b972c4d59c1c2d6da3deb3bf52","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al actualizar cantidad: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"75a7c65d371cbd0a0ed28b79d4e6e896","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":118,"column":13},"end":{"line":118,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"0ed39a73089454b07426fbc76fee8be7","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error al actualizar cantidad'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":119,"column":13},"end":{"line":119,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"5275bf8d1f640c54ab401f64ce141b2e","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error al actualizar cantidad'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":119,"column":13},"end":{"line":119,"column":86}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dbc96c03f3b64a74b10909e936648484","861ce129fc3196e3f58b8d7dc15e77f8"],"killedBy":[],"testsCompleted":0},{"id":"522197318da3bd61a75e72545ad15c5c","mutatorName":"PublicVisibility","replacement":"protected function deleteCartItem($cartId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":123,"column":5},"end":{"line":123,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8b777577a59cbaa568701bb5fa606fc0","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"0c55f120518f96672e0d003d4c509474","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":127,"column":13},"end":{"line":127,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8b777577a59cbaa568701bb5fa606fc0"],"killedBy":[],"testsCompleted":0},{"id":"7756a071741569b40c01cd7a0576aba1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":127,"column":13},"end":{"line":127,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8b777577a59cbaa568701bb5fa606fc0"],"killedBy":[],"testsCompleted":0},{"id":"02ae467303479c04e63d40a9b9ecd4ef","mutatorName":"TrueValue","replacement":"return false;","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":128,"column":13},"end":{"line":128,"column":25}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 538 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:149\n\nFAILURES!\r\nTests: 5, Assertions: 17, Failures: 1.\r\n","coveredBy":["8b777577a59cbaa568701bb5fa606fc0"],"killedBy":["8b777577a59cbaa568701bb5fa606fc0"],"testsCompleted":5},{"id":"481706adb6e33cbd18f39166c7917cf9","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al eliminar item: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"99ef156ac0ff799d1a413764f986af93","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"f07b7f491354a1f15c993e61ef0df211","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al eliminar item: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"80c004aac72dbabfdbd00ddb00c3b8d9","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":130,"column":13},"end":{"line":130,"column":70}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"9a0d3ab9b20de76c20ef894ce56669a9","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":131,"column":13},"end":{"line":131,"column":26}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["90d2b1363c2387d208e61551e5d81906","8d3a5cdebb924a18bbd6039914683cec"],"killedBy":[],"testsCompleted":0},{"id":"308fbcfacbf6d4c16bfc0113ed6b28fe","mutatorName":"PublicVisibility","replacement":"protected function deleteAllCartItems($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":135,"column":5},"end":{"line":135,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nError: Call to protected method Controllers\\ProductController::deleteAllCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:166\n\nERRORS!\r\nTests: 6, Assertions: 19, Errors: 1.\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00","533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"6e114c4ab7e2f414afa7e52bdfd422cb","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":139,"column":13},"end":{"line":139,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\n\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1.\r\n","coveredBy":["533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"5aae6d73a37c216cab4db08ce7ad3ac6","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":139,"column":13},"end":{"line":139,"column":39}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 6, Assertions: 22, Failures: 1.\r\n","coveredBy":["533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"342ed970ca1ab0f9eb5602796b648c9b","mutatorName":"TrueValue","replacement":"return false;","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":140,"column":13},"end":{"line":140,"column":25}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\n\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1.\r\n","coveredBy":["533c884852c9465706da5a94e08ac4b2"],"killedBy":["533c884852c9465706da5a94e08ac4b2"],"testsCompleted":6},{"id":"e148a239925d471433a1421bb3d3e911","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al eliminar todos los items: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"625eccb5c274d1687527f10a1551b2fa","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"f2f7c7113613af5584a6953b8d3fca31","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al eliminar todos los items: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"a8ead461abb707e1c82c5b4631444787","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":142,"column":13},"end":{"line":142,"column":81}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................ 16 \/ 16 (100%)\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":[],"testsCompleted":0},{"id":"39f59d6ad0595696c17a38602edc6600","mutatorName":"FalseValue","replacement":"return true;","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":143,"column":13},"end":{"line":143,"column":26}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.............F\nNotice: fwrite(): Write of 1386 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:317\n\nFAILURES!\r\nTests: 14, Assertions: 47, Failures: 1.\r\n","coveredBy":["9079b2b01975467bd588ac0635613e00"],"killedBy":["9079b2b01975467bd588ac0635613e00"],"testsCompleted":14}]},"Controllers\/SearchController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n public function searchProducts($searchTerm) {\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";\r\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\r\n $stmt->execute([$searchTerm]);\r\n \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n return [];\r\n }\r\n }\r\n} ","mutants":[{"id":"1b53660b7664fdc49d4ff09f09eef290","mutatorName":"PublicVisibility","replacement":"protected function searchProducts($searchTerm)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":11,"column":5},"end":{"line":11,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 217 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados\nError: Call to protected method Controllers\\SearchController::searchProducts() from scope Tests\\Unit\\Controllers\\SearchControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:38\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["119dcc727a6c5c37089ce369397e3936","38f507e5499b7d283bd2d73a0e5dab72","9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["38f507e5499b7d283bd2d73a0e5dab72"],"testsCompleted":1},{"id":"e06dd7f9ae3c6dc0ab29eec89bf75650","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":15,"column":13},"end":{"line":15,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1.\r\n","coveredBy":["119dcc727a6c5c37089ce369397e3936","38f507e5499b7d283bd2d73a0e5dab72"],"killedBy":["08bac488cb269f384def5af24b61d002"],"testsCompleted":4},{"id":"928a3b37b4a528c89295bc4f76e56157","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":15,"column":13},"end":{"line":15,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...F\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nParameter 0 for invocation PDOStatement::execute(Array ()): bool does not match expected value.\nFailed asserting that two arrays are equal.\n--- Expected\n+++ Actual\n@@ @@\n Array (\n- 0 => '%%'\n )\n\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1.\r\n","coveredBy":["119dcc727a6c5c37089ce369397e3936","38f507e5499b7d283bd2d73a0e5dab72"],"killedBy":["08bac488cb269f384def5af24b61d002"],"testsCompleted":4},{"id":"79fa78ac3915f90a1f841a68248280dc","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en b\u00fasqueda: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '[11-Dec-2024 23:16:41 Europe\/Berlin] Error de pruebaError en b\u00fasqueda: \\r\\n\n' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5},{"id":"3568f49bca400f1501d0c67eb800a0d8","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '[11-Dec-2024 23:16:41 Europe\/Berlin] Error de prueba\\r\\n\n' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5},{"id":"577e5d590dc49afd50853644d046927d","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en b\u00fasqueda: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '[11-Dec-2024 23:16:41 Europe\/Berlin] Error en b\u00fasqueda: \\r\\n\n' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5},{"id":"874cb741ca2c3b125473262c4d449fd0","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":19,"column":13},"end":{"line":19,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F 5 \/ 5 (100%)\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\nFailed asserting that '' contains \"Error en b\u00fasqueda: Error de prueba\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\n\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1.\r\n","coveredBy":["9499b5d588e5718df0bbb5d28d1d7337"],"killedBy":["08c05d69ad8e704fff6bb20383e9a536"],"testsCompleted":5}]},"Controllers\/UserController.php":{"language":"php","source":"conn = $conn;\r\n }\r\n\r\n private function hashPassword($password) {\r\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n }\r\n\r\n private function verifyPassword($password, $hashedPassword) {\r\n return password_verify($password, $hashedPassword);\r\n }\r\n\r\n public function registerUser($userData) {\r\n try {\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n $user->setEmail($userData['email']);\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);\r\n if($stmt->fetch()) {\r\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }\r\n\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\r\n \"INSERT INTO users (name, email, password, user_type) \r\n VALUES (?, ?, ?, ?)\"\r\n );\r\n \r\n $stmt->execute([\r\n $user->getName(),\r\n $user->getEmail(),\r\n $this->hashPassword($userData['password']),\r\n $user->getUserType()\r\n ]);\r\n \r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }\r\n\r\n public function loginUser($email, $password) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n $stmt->execute([$email]);\r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n\r\n if ($user && $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];\r\n $_SESSION['user_email'] = $user['email'];\r\n return ['success' => true, 'user_type' => $user['user_type']];\r\n }\r\n\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }\r\n\r\n public function logout() {\r\n try {\r\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\r\n if (session_status() === PHP_SESSION_NONE) {\r\n session_start();\r\n }\r\n \r\n \/\/ Limpiar todas las variables de sesi\u00f3n\r\n $_SESSION = array();\r\n \r\n \/\/ Destruir la sesi\u00f3n\r\n session_destroy();\r\n \r\n \/\/ Redireccionar al login\r\n header('location: ..\/auth\/login.php');\r\n exit();\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en logout: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\r\n }\r\n }\r\n\r\n public function getUserById($userId) {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n return null;\r\n }\r\n }\r\n\r\n \/\/ Alias para mantener compatibilidad\r\n public function register($userData) {\r\n return $this->registerUser($userData);\r\n }\r\n} ","mutants":[{"id":"5c7d14398573f28a8168a9e3aa94f1d6","mutatorName":"ArrayItemRemoval","replacement":"return password_hash($password, PASSWORD_BCRYPT, []);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":15,"column":9},"end":{"line":15,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 1133 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.463, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\nFailed asserting that '$2y$10$N7gH5\/6HoxJt6GSTuNb3X.S6XZ3HPrrJ7CqcMAllxeu8fXeSIe3xe' contains \"$2y$12$\".\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:244\n\nFAILURES!\r\nTests: 12, Assertions: 23, Failures: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","c5f619a697779b293907d101b23e2cc5","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["c5f619a697779b293907d101b23e2cc5"],"testsCompleted":12},{"id":"738b4ea5c36a7e50d82122b39a6328e8","mutatorName":"FunctionCall","replacement":"password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n return null;","description":"Replaces a returned evaluated function with `null` instead. The function evaluation statement is kept\nin order to preserve potential side effects. For example:\n\n```php\nclass X {\n function foo()\n {\n return bar();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo()\n {\n bar();\n return null;\n }\n}\n```\n","location":{"start":{"line":15,"column":9},"end":{"line":15,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........F\nNotice: fwrite(): Write of 1137 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:01.220, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:243\n\nFAILURES!\r\nTests: 12, Assertions: 22, Failures: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","c5f619a697779b293907d101b23e2cc5","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["c5f619a697779b293907d101b23e2cc5"],"testsCompleted":12},{"id":"0719ff7f8976df5f9520fe675d12f6a9","mutatorName":"FunctionCall","replacement":"password_verify($password, $hashedPassword);\r\n return null;","description":"Replaces a returned evaluated function with `null` instead. The function evaluation statement is kept\nin order to preserve potential side effects. For example:\n\n```php\nclass X {\n function foo()\n {\n return bar();\n }\n}\n```\n\nWill be mutated to:\n\n```php\nclass X {\n function foo()\n {\n bar();\n return null;\n }\n}\n```\n","location":{"start":{"line":19,"column":9},"end":{"line":19,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.339, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:73\n\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","e90d3c5d6475a8b9876cd1a2fd342fc2","c0b609be3f46cabd11f9479c3867ba10","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","bc66590a599c81f251afe7f022704124","7a41cc8095f8763e256eeeabc2964148"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"8dde8a9053d96b8733621c7d6f84f757","mutatorName":"PublicVisibility","replacement":"protected function registerUser($userData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 190 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\nError: Call to protected method Controllers\\UserController::registerUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:42\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["4e5d456bcd3f0f480afe371d6ab58a3a"],"testsCompleted":1},{"id":"88ac82b58817201202f1520e653d9549","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":25,"column":13},"end":{"line":25,"column":47}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.386, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"343af5360ff837a558ed686daa26c48f","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":26,"column":13},"end":{"line":26,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2836 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.399, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"a40cd7fc558936e3df77cfc7dce03a81","mutatorName":"Coalesce","replacement":"$user->setUserType('user' ?? $userData['user_type']);","description":"Swaps the coalesce operator (`??`) operands,\ne.g. replaces `$a ?? $b` with `$b ?? $a` or `$a ?? $b ?? $c` with `$b ?? $a ?? $c` and `$a ?? $c ?? $b`.","location":{"start":{"line":27,"column":13},"end":{"line":27,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.441, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"280066033e5ce7f7f3be0f84088f8eb9","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":27,"column":13},"end":{"line":27,"column":66}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.396, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"3dbd4a9ae6e29b786f505758b48734bf","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":31,"column":13},"end":{"line":31,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.390, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"caea43ad25065db4011a9d2e17221460","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":31,"column":13},"end":{"line":31,"column":49}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.783, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"5e7c850525b5c190daf92173cd4974b9","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'El correo ya est\u00e1 registrado'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":33,"column":17},"end":{"line":33,"column":91}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....F\nNotice: fwrite(): Write of 550 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.334, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:128\n\nFAILURES!\r\nTests: 5, Assertions: 10, Failures: 1.\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","5562fefd1e6267f1330a8be9c24c0c1e"],"killedBy":["cf7f861e585d3046cc970897756c7229"],"testsCompleted":5},{"id":"beb970f03de23216fc17a6f76c7bab2d","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'El correo ya est\u00e1 registrado'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":33,"column":17},"end":{"line":33,"column":91}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 549 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.350, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:128\n\nERRORS!\r\nTests: 5, Assertions: 9, Errors: 1.\r\n","coveredBy":["cf7f861e585d3046cc970897756c7229","5562fefd1e6267f1330a8be9c24c0c1e"],"killedBy":["cf7f861e585d3046cc970897756c7229"],"testsCompleted":5},{"id":"24ab589e57076ff1f172e8f8484814a7","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":42,"column":13},"end":{"line":47,"column":16}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................E 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2898 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:01.281, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\nUndefined array key 3\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:641\n\nERRORS!\r\nTests: 33, Assertions: 60, Errors: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["82b33ea8be7f215b2cef162114a6d5c3"],"testsCompleted":33},{"id":"21f2d16ca4933351ea8de87f9521b85c","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":42,"column":13},"end":{"line":47,"column":29}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................E 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2925 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.411, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\nUndefined array key 3\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:641\n\nERRORS!\r\nTests: 33, Assertions: 60, Errors: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["82b33ea8be7f215b2cef162114a6d5c3"],"testsCompleted":33},{"id":"afe810cfe705a043850a1e9ea546a079","mutatorName":"TrueValue","replacement":"return ['success' => false, 'message' => 'Registro exitoso!'];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":49,"column":13},"end":{"line":49,"column":74}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nF\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.235, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\nFailed asserting that false is identical to true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:48\n\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["4e5d456bcd3f0f480afe371d6ab58a3a"],"testsCompleted":1},{"id":"84bc447e93f0196e863626eb6355258d","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Registro exitoso!'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":49,"column":13},"end":{"line":49,"column":74}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.243, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:48\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["4e5d456bcd3f0f480afe371d6ab58a3a"],"testsCompleted":1},{"id":"9beadead9da3a13eaa9a5859ce0e8562","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en registro: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.404, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"10d8096bc7e3f58cab36bc627f7f70a8","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2832 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.383, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"476be47e67cce512fcd1b0dccff5f720","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en registro: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.379, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"f1a4e74b3a2448645f1c25ddbfc747ea","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":51,"column":13},"end":{"line":51,"column":65}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2832 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.386, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":[],"testsCompleted":0},{"id":"45670895b720aa18fe43b100e7d3712f","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error en el registro'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":52,"column":13},"end":{"line":52,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....F\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.338, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:146\n\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1.\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["1884bc4f1d1fef63116444d66c172e6b"],"testsCompleted":6},{"id":"7449317dbffa6f21bff28584d2724102","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error en el registro'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":52,"column":13},"end":{"line":52,"column":78}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:146\n\nERRORS!\r\nTests: 6, Assertions: 11, Errors: 1.\r\n","coveredBy":["1648e182f0dec8698cc3c000b7c001fe","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["1884bc4f1d1fef63116444d66c172e6b"],"testsCompleted":6},{"id":"16763f03a1d5d0d0c6f0278176776ba6","mutatorName":"PublicVisibility","replacement":"protected function loginUser($email, $password)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":56,"column":5},"end":{"line":56,"column":51}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.296, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nError: Call to protected method Controllers\\UserController::loginUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:71\n\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"17fe93b273d2985ac03367be5f5b4d51","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 688 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Error en el inicio de sesi\u00f3n'\n+'Correo o contrase\u00f1a incorrectos'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:161\n\nFAILURES!\r\nTests: 7, Assertions: 15, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["dc1973acbaca0a28a598effc18237ad0"],"testsCompleted":7},{"id":"30721036ae14caed212b1591eb511824","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":59,"column":13},"end":{"line":59,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........................F\nNotice: fwrite(): Write of 2462 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:02.392, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_parametros_vacios\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Error en el inicio de sesi\u00f3n'\n+'Correo o contrase\u00f1a incorrectos'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:516\n\nFAILURES!\r\nTests: 28, Assertions: 48, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["8f6806446dc730bfa17ccb11eb2d00c1"],"testsCompleted":28},{"id":"16d0632e9cd3710147f6dde9fac3f1f0","mutatorName":"LogicalAnd","replacement":"if ($user || $this->verifyPassword($password, $user['password'])) {","description":"Replaces an AND operator (`&&`) with an OR operator (`||`).","location":{"start":{"line":62,"column":13},"end":{"line":62,"column":80}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.297, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\nFailed asserting that two strings are identical.\n--- Expected\n+++ Actual\n@@ @@\n-'Correo o contrase\u00f1a incorrectos'\n+'Error en el inicio de sesi\u00f3n'\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:89\n\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","7e243c64fb424b58831479362b095622","f68eb8b986d9fc309ed29c287efd52cb","2c9e012a8ef82162dc733a7d5ed147cb","377db5af9ac5ffe374c7f038544ba613","bc66590a599c81f251afe7f022704124","7a41cc8095f8763e256eeeabc2964148","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["377db5af9ac5ffe374c7f038544ba613"],"testsCompleted":3},{"id":"d16518173c8347fb3a86ac316825b0d4","mutatorName":"TrueValue","replacement":"return ['success' => false, 'user_type' => $user['user_type']];","description":"Replaces a boolean literal (`true`) with its opposite value (`false`). ","location":{"start":{"line":67,"column":17},"end":{"line":67,"column":79}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.F\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nFailed asserting that false is true.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:73\n\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1.\r\n","coveredBy":["2c9e012a8ef82162dc733a7d5ed147cb","bc66590a599c81f251afe7f022704124"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"bc98c8772c8965bc069b76d217563515","mutatorName":"ArrayItemRemoval","replacement":"return ['user_type' => $user['user_type']];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":67,"column":17},"end":{"line":67,"column":79}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.361, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:73\n\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1.\r\n","coveredBy":["2c9e012a8ef82162dc733a7d5ed147cb","bc66590a599c81f251afe7f022704124"],"killedBy":["bc66590a599c81f251afe7f022704124"],"testsCompleted":2},{"id":"bce68386ab606a2349c0a3b542568e23","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Correo o contrase\u00f1a incorrectos'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":90}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..F\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.362, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\nFailed asserting that true is identical to false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:88\n\nFAILURES!\r\nTests: 3, Assertions: 5, Failures: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","f68eb8b986d9fc309ed29c287efd52cb","377db5af9ac5ffe374c7f038544ba613","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["377db5af9ac5ffe374c7f038544ba613"],"testsCompleted":3},{"id":"da7a171e99dd467cded6998ad76deb1a","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Correo o contrase\u00f1a incorrectos'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":70,"column":13},"end":{"line":70,"column":90}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.362, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:88\n\nERRORS!\r\nTests: 3, Assertions: 4, Errors: 1.\r\n","coveredBy":["1f53110b52fbcb82fad3d83ce886911f","f68eb8b986d9fc309ed29c287efd52cb","377db5af9ac5ffe374c7f038544ba613","f94ca319ab2dfc219b33dcd743cfeb5f"],"killedBy":["377db5af9ac5ffe374c7f038544ba613"],"testsCompleted":3},{"id":"b4199a70eef327c50b833f9c5555f0b7","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error en login: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.359, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"b76d5b9100e95dd8aa6fa3aa20c248a9","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2838 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.349, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"e209385317906488e93b10a361a2f412","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error en login: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.404, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"88dc5b029aa89f1a4af55357887df49a","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":72,"column":13},"end":{"line":72,"column":62}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.361, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":[],"testsCompleted":0},{"id":"d93c581d9b9142b82bab2b94b70d1887","mutatorName":"FalseValue","replacement":"return ['success' => true, 'message' => 'Error en el inicio de sesi\u00f3n'];","description":"Replaces a boolean literal (`false`) with its opposite value (`true`). ","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......F\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\nFailed asserting that true is false.\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:160\n\nFAILURES!\r\nTests: 7, Assertions: 14, Failures: 1.\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":["dc1973acbaca0a28a598effc18237ad0"],"testsCompleted":7},{"id":"5ea83094147bb1955d2f7571d37a1da5","mutatorName":"ArrayItemRemoval","replacement":"return ['message' => 'Error en el inicio de sesi\u00f3n'];","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":73,"column":13},"end":{"line":73,"column":87}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.353, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\nUndefined array key \"success\"\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:160\n\nERRORS!\r\nTests: 7, Assertions: 13, Errors: 1.\r\n","coveredBy":["88913d5fb1ca58b323af46d3e38f8b37","7e243c64fb424b58831479362b095622","dc1973acbaca0a28a598effc18237ad0","7a41cc8095f8763e256eeeabc2964148"],"killedBy":["dc1973acbaca0a28a598effc18237ad0"],"testsCompleted":7},{"id":"d6f06b8d343436d0d566a506e366801b","mutatorName":"PublicVisibility","replacement":"protected function getUserById($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":99,"column":5},"end":{"line":99,"column":43}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 459 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.349, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id\nError: Call to protected method Controllers\\UserController::getUserById() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:106\n\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1.\r\n","coveredBy":["a3214e814150e4694e5bde76166b4a2b","6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d","ebc491f7be9fdad3965e5ccdf30566c6","62b48a5e15de8d584745b990f5316ddb"],"killedBy":["ebc491f7be9fdad3965e5ccdf30566c6"],"testsCompleted":4},{"id":"f651a6456dc6265a0a8454dedc4d49a3","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":102,"column":13},"end":{"line":102,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2838 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.390, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["a3214e814150e4694e5bde76166b4a2b","6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d","ebc491f7be9fdad3965e5ccdf30566c6","62b48a5e15de8d584745b990f5316ddb"],"killedBy":[],"testsCompleted":0},{"id":"dd29834c47f796a3e2c0c5b2b4d937d1","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":102,"column":13},"end":{"line":102,"column":39}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.338, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["a3214e814150e4694e5bde76166b4a2b","6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d","ebc491f7be9fdad3965e5ccdf30566c6","62b48a5e15de8d584745b990f5316ddb"],"killedBy":[],"testsCompleted":0},{"id":"4f9430b4ee2794c1a4821376bbbcd075","mutatorName":"Concat","replacement":"error_log($e->getMessage() . \"Error al obtener usuario: \");","description":"Flips the operands of the string concatenation operator `.`. For example:\n\n```php\n'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n'bar' . 'foo';\n```","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2836 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.376, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"bb9ba792029d68b0a4daeffca9257b24","mutatorName":"ConcatOperandRemoval","replacement":"error_log($e->getMessage());","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.391, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"17b7f1db4eb950d4976c0376e3ae1af4","mutatorName":"FunctionCallRemoval","replacement":"","description":"Removes the function call.","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.461, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"098b40e57246dffceb49edff37d66d1d","mutatorName":"ConcatOperandRemoval","replacement":"error_log(\"Error al obtener usuario: \");","description":"Removes an operand from a string concatenation.\n\n```php\n$x = 'foo' . 'bar';\n```\n\nWill be mutated to:\n\n```php\n$x = 'foo';\n```\n\nAnd:\n\n```php\n$x = 'bar';\n","location":{"start":{"line":105,"column":13},"end":{"line":105,"column":72}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................. 33 \/ 33 (100%)\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:03.535, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)\r\n","coveredBy":["6511508b57f48da46af4c82281794cb0","baeba2b0443c9006dae99054a84bf92d"],"killedBy":[],"testsCompleted":0},{"id":"7fbec6fd2ce178710277d50b17eea149","mutatorName":"PublicVisibility","replacement":"protected function register($userData)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":111,"column":5},"end":{"line":111,"column":42}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 941 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.553, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register\nError: Call to protected method Controllers\\UserController::register() from scope Tests\\Unit\\Controllers\\UserControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:206\n\nERRORS!\r\nTests: 10, Assertions: 18, Errors: 1.\r\n","coveredBy":["5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["5f1ac69ed727a6a2093d161091ef2238"],"testsCompleted":10}]},"Exceptions\/DatabaseException.php":{"language":"php","source":"id; }\r\n public function getUserId() { return $this->userId; }\r\n public function getName() { return $this->name; }\r\n public function getPrice() { return $this->price; }\r\n public function getQuantity() { return $this->quantity; }\r\n public function getImage() { return $this->image; }\r\n\r\n \/\/ Setters\r\n public function setUserId($userId) { $this->userId = $userId; }\r\n public function setName($name) { $this->name = $name; }\r\n public function setPrice($price) { $this->price = $price; }\r\n public function setQuantity($quantity) { $this->quantity = $quantity; }\r\n public function setImage($image) { $this->image = $image; }\r\n} ","mutants":[{"id":"a2131e7a148aa9494015c5c650c8c832","mutatorName":"PublicVisibility","replacement":"protected function getUserId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":14,"column":5},"end":{"line":14,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getUserId() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:63\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"9c1fadc9e55e723829a99d4e07ba25be","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":15,"column":5},"end":{"line":15,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"92ad38d69dbb0a57e52ca518c9f0fc57","mutatorName":"PublicVisibility","replacement":"protected function getPrice()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":16,"column":5},"end":{"line":16,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.025, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getPrice() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:65\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"b5069b312fefd6cee2b6bcc06042962c","mutatorName":"PublicVisibility","replacement":"protected function getQuantity()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getQuantity() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:66\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"f85ecb8bee4c3007da6bc019811aa092","mutatorName":"PublicVisibility","replacement":"protected function getImage()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\nError: Call to protected method Models\\Cart::getImage() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:67\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\n\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1.\r\n","coveredBy":["496122c302addcbe11f203caffa7d24f"],"killedBy":["496122c302addcbe11f203caffa7d24f"],"testsCompleted":2},{"id":"57ca1ca2f090527721ac6221bc0276d8","mutatorName":"PublicVisibility","replacement":"protected function setUserId($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"913393895f84efe9a7161fe0256b4aa6","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"8e481315494a5baccbce668972d6ab2b","mutatorName":"PublicVisibility","replacement":"protected function setPrice($price)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"b61530515ee44861833da34dc5b15609","mutatorName":"PublicVisibility","replacement":"protected function setQuantity($quantity)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0},{"id":"413f4b0a8ac2fc3f6336947c539b5157","mutatorName":"PublicVisibility","replacement":"protected function setImage($image)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":25,"column":5},"end":{"line":25,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found\r\n","coveredBy":["dc7b02abddb2408e22973baf42d4b091","6fe2e83f565ec7dff367868cae77e679","21b277a20d75495834b915634005099f","496122c302addcbe11f203caffa7d24f"],"killedBy":[],"testsCompleted":0}]},"Models\/Message.php":{"language":"php","source":"id; }\r\n public function getUserId() { return $this->userId; }\r\n public function getName() { return $this->name; }\r\n public function getEmail() { return $this->email; }\r\n public function getNumber() { return $this->number; }\r\n public function getMessage() { return $this->message; }\r\n\r\n \/\/ Setters\r\n public function setUserId($userId) { $this->userId = $userId; }\r\n public function setName($name) { $this->name = $name; }\r\n public function setEmail($email) { $this->email = $email; }\r\n public function setNumber($number) { $this->number = $number; }\r\n public function setMessage($message) { $this->message = $message; }\r\n\r\n public function exists($conn) {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);\r\n $stmt->execute([$this->userId, $this->message]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n\r\n public function save($conn) {\r\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $conn->prepare($sql);\r\n return $stmt->execute([\r\n $this->userId,\r\n $this->name,\r\n $this->email,\r\n $this->number,\r\n $this->message\r\n ]);\r\n }\r\n\r\n public function setId($id) { $this->id = $id; }\r\n} ","mutants":[{"id":"228f125cdebcdeadcd41e08c8ed9d512","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":13,"column":5},"end":{"line":13,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\nError: Call to protected method Models\\Message::getId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:28\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["526a8af9ac30be501c7f4b37124d576f"],"killedBy":["526a8af9ac30be501c7f4b37124d576f"],"testsCompleted":1},{"id":"777979e737c9911d705760828ab4d590","mutatorName":"PublicVisibility","replacement":"protected function getUserId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":14,"column":5},"end":{"line":14,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 256 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\nError: Call to protected method Models\\Message::getUserId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:36\n\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1.\r\n","coveredBy":["982c4d44a4015074431dc655f61bf9c9"],"killedBy":["982c4d44a4015074431dc655f61bf9c9"],"testsCompleted":2},{"id":"d81474f147a42513673c33ed1912c99f","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":15,"column":5},"end":{"line":15,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.020, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\nError: Call to protected method Models\\Message::getName() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:44\n\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1.\r\n","coveredBy":["2b1642fa5d7b37210b33ee2a94697390"],"killedBy":["2b1642fa5d7b37210b33ee2a94697390"],"testsCompleted":3},{"id":"a024a981caafb460e3f2edf7766f19b0","mutatorName":"PublicVisibility","replacement":"protected function getEmail()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":16,"column":5},"end":{"line":16,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.020, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\nError: Call to protected method Models\\Message::getEmail() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:52\n\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","19542864ba4ef81044cd17038a6e8c59"],"killedBy":["19542864ba4ef81044cd17038a6e8c59"],"testsCompleted":4},{"id":"2d27e77e56ca53d21c0bc139aef41d46","mutatorName":"PublicVisibility","replacement":"protected function getNumber()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.019, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\nError: Call to protected method Models\\Message::getNumber() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:60\n\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1.\r\n","coveredBy":["acf82b784e1fde7256a6c27e70355a65"],"killedBy":["acf82b784e1fde7256a6c27e70355a65"],"testsCompleted":5},{"id":"b8773819023d633a3575d28eaeeefec2","mutatorName":"PublicVisibility","replacement":"protected function getMessage()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\nError: Call to protected method Models\\Message::getMessage() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:68\n\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","83c78b91f60c0ee0e7c5af4cda4ca08c"],"killedBy":["83c78b91f60c0ee0e7c5af4cda4ca08c"],"testsCompleted":6},{"id":"e02eff8937e71705a2a2021358f67769","mutatorName":"PublicVisibility","replacement":"protected function setUserId($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\nError: Call to protected method Models\\Message::setUserId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:35\n\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","09cbcccec0a12bf6ed83725861831d3b","9fac10250403152dbfd443e6d82c8728","982c4d44a4015074431dc655f61bf9c9"],"killedBy":["982c4d44a4015074431dc655f61bf9c9"],"testsCompleted":2},{"id":"baa9f0594b32fba290f03ef75dbee02f","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\nError: Call to protected method Models\\Message::setName() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:43\n\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728","2b1642fa5d7b37210b33ee2a94697390"],"killedBy":["2b1642fa5d7b37210b33ee2a94697390"],"testsCompleted":3},{"id":"2fc545178dae19a6ebf5437259901f43","mutatorName":"PublicVisibility","replacement":"protected function setEmail($email)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\nError: Call to protected method Models\\Message::setEmail() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:51\n\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728","19542864ba4ef81044cd17038a6e8c59"],"killedBy":["19542864ba4ef81044cd17038a6e8c59"],"testsCompleted":4},{"id":"48709a983e17cafabbcf9de84d625457","mutatorName":"PublicVisibility","replacement":"protected function setNumber($number)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n....E\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.020, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\nError: Call to protected method Models\\Message::setNumber() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:59\n\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728","acf82b784e1fde7256a6c27e70355a65"],"killedBy":["acf82b784e1fde7256a6c27e70355a65"],"testsCompleted":5},{"id":"f9050a2c4accf576a1277882ac7b2bc7","mutatorName":"PublicVisibility","replacement":"protected function setMessage($message)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":25,"column":5},"end":{"line":25,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.....E\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\nError: Call to protected method Models\\Message::setMessage() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:67\n\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","4813abd1aac2f55ae34e6218d3266a72","09cbcccec0a12bf6ed83725861831d3b","9fac10250403152dbfd443e6d82c8728","83c78b91f60c0ee0e7c5af4cda4ca08c"],"killedBy":["83c78b91f60c0ee0e7c5af4cda4ca08c"],"testsCompleted":6},{"id":"d6b5994a2b17f64161a9fa6ad42b09da","mutatorName":"PublicVisibility","replacement":"protected function exists($conn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":27,"column":5},"end":{"line":27,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E 9 \/ 9 (100%)\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\nError: Call to protected method Models\\Message::exists() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:128\n\nERRORS!\r\nTests: 9, Assertions: 12, Errors: 1.\r\n","coveredBy":["09cbcccec0a12bf6ed83725861831d3b"],"killedBy":["09cbcccec0a12bf6ed83725861831d3b"],"testsCompleted":9},{"id":"c4ca60b925843ac6ecec8f2d99fc1c51","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([$this->message]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":30,"column":9},"end":{"line":30,"column":57}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......... 9 \/ 9 (100%)\nNotice: fwrite(): Write of 672 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)\r\n","coveredBy":["09cbcccec0a12bf6ed83725861831d3b"],"killedBy":[],"testsCompleted":0},{"id":"8569ef4543891a57003e45e35bce4534","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":30,"column":9},"end":{"line":30,"column":57}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........F 9 \/ 9 (100%)\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.025, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\n\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\nMethod was expected to be called 1 times, actually called 0 times.\n\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1.\r\n","coveredBy":["09cbcccec0a12bf6ed83725861831d3b"],"killedBy":["09cbcccec0a12bf6ed83725861831d3b"],"testsCompleted":9},{"id":"de4e6ffdab2fe70be2072b7dd08d82cf","mutatorName":"PublicVisibility","replacement":"protected function save($conn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":34,"column":5},"end":{"line":34,"column":34}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 590 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje\nError: Call to protected method Models\\Message::save() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:88\n\nERRORS!\r\nTests: 7, Assertions: 6, Errors: 1.\r\n","coveredBy":["4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728"],"killedBy":["4813abd1aac2f55ae34e6218d3266a72"],"testsCompleted":7},{"id":"24e24d7f7d71d379da4846228c647b01","mutatorName":"ArrayItemRemoval","replacement":"return $stmt->execute([$this->name, $this->email, $this->number, $this->message]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":37,"column":9},"end":{"line":43,"column":32}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......... 9 \/ 9 (100%)\nNotice: fwrite(): Write of 668 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)\r\n","coveredBy":["4813abd1aac2f55ae34e6218d3266a72","9fac10250403152dbfd443e6d82c8728"],"killedBy":[],"testsCompleted":0},{"id":"2310043b6b321e22f9472a24dd1adfe8","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":46,"column":5},"end":{"line":46,"column":52}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\nError: Call to protected method Models\\Message::setId() from scope Tests\\Unit\\Models\\MessageTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:27\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["36243924380b2e3a203435fb9bdce1d1","526a8af9ac30be501c7f4b37124d576f"],"killedBy":["526a8af9ac30be501c7f4b37124d576f"],"testsCompleted":1}]},"Models\/Order.php":{"language":"php","source":"id; }\r\n public function getUserId() { return $this->userId; }\r\n public function getName() { return $this->name; }\r\n public function getNumber() { return $this->number; }\r\n public function getEmail() { return $this->email; }\r\n public function getMethod() { return $this->method; }\r\n public function getAddress() { return $this->address; }\r\n public function getTotalProducts() { return $this->totalProducts; }\r\n public function getTotalPrice() { return $this->totalPrice; }\r\n public function getPlacedOn() { return $this->placedOn; }\r\n public function getPaymentStatus() { return $this->paymentStatus; }\r\n\r\n \/\/ Setters\r\n public function setUserId($userId) { $this->userId = $userId; }\r\n public function setName($name) { $this->name = $name; }\r\n public function setNumber($number) { $this->number = $number; }\r\n public function setEmail($email) { $this->email = $email; }\r\n public function setMethod($method) { $this->method = $method; }\r\n public function setAddress($address) { $this->address = $address; }\r\n public function setTotalProducts($totalProducts) { $this->totalProducts = $totalProducts; }\r\n public function setTotalPrice($totalPrice) { $this->totalPrice = $totalPrice; }\r\n public function setPaymentStatus($status) { $this->paymentStatus = $status; }\r\n public function setPlacedOn($placedOn) { $this->placedOn = $placedOn; }\r\n\r\n public function setId($id) {\r\n $this->id = $id;\r\n return $this;\r\n }\r\n} ","mutants":[{"id":"63bd49d5fc302bdfedbd85612b31a494","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\nError: Call to protected method Models\\Order::getId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:326\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\n\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1.\r\n","coveredBy":["9f4d645aba7ebec46f8fa49817ad0027","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["9cf07fc703009bc41d2d6794677c2465"],"testsCompleted":3},{"id":"913fb692e2e9c37e3f35d0989f5d5e9b","mutatorName":"PublicVisibility","replacement":"protected function getUserId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":19,"column":5},"end":{"line":19,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getUserId() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:161\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"74a45caf698ef5b2efb8d437a218317c","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":20,"column":5},"end":{"line":20,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getName() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:141\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"c8d2aff30a1dde8c3a01643a14c26dfa","mutatorName":"PublicVisibility","replacement":"protected function getNumber()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getNumber() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:142\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"8823c16d271997b09b59873492a14c07","mutatorName":"PublicVisibility","replacement":"protected function getEmail()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getEmail() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:143\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"613b926c9561f32afd3261ed1ac3b595","mutatorName":"PublicVisibility","replacement":"protected function getMethod()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":58}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getMethod() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:144\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"633c102c14dbaef64a9658d4c00255d4","mutatorName":"PublicVisibility","replacement":"protected function getAddress()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getAddress() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:145\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"cb5ee3637f3d77e6b7da593feae5a846","mutatorName":"PublicVisibility","replacement":"protected function getTotalProducts()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":25,"column":5},"end":{"line":25,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getTotalProducts() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:146\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"32d627f962cd6c9c73e7d20460b7724b","mutatorName":"PublicVisibility","replacement":"protected function getTotalPrice()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":26,"column":5},"end":{"line":26,"column":66}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::getTotalPrice() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:147\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"f82d6a7b6041cb2a0b6f90e9ed6afe11","mutatorName":"PublicVisibility","replacement":"protected function getPaymentStatus()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":28,"column":5},"end":{"line":28,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\nError: Call to protected method Models\\Order::getPaymentStatus() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:326\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\n\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1.\r\n","coveredBy":["e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["9cf07fc703009bc41d2d6794677c2465"],"testsCompleted":3},{"id":"88a868717280e767ad64dea879ba6117","mutatorName":"PublicVisibility","replacement":"protected function setUserId($userId)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":31,"column":5},"end":{"line":31,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"337aa315c12a084474a3aa5ad69e27ca","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":32,"column":5},"end":{"line":32,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"5bfa69ce65ca15763c6ced4109e6c2f3","mutatorName":"PublicVisibility","replacement":"protected function setNumber($number)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":33,"column":5},"end":{"line":33,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"75d6cedf938fe8ca8e982173122b4e86","mutatorName":"PublicVisibility","replacement":"protected function setEmail($email)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":34,"column":5},"end":{"line":34,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"dbc80e732884d163270102613d749cab","mutatorName":"PublicVisibility","replacement":"protected function setMethod($method)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":35,"column":5},"end":{"line":35,"column":68}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found\r\n","coveredBy":["17fc22fdee4bdc93146edb702b18eb90","e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","9b1d437f68a23ef8f0c60f232232f51c","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06","7a701a7b1ab59a11ed7dcb7f27545ae6"],"killedBy":[],"testsCompleted":0},{"id":"252b9a67b5cb559217d0d5577c11a918","mutatorName":"PublicVisibility","replacement":"protected function setAddress($address)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":36,"column":5},"end":{"line":36,"column":72}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.030, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::setAddress() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:130\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"0c21729cc9c830e0ab24f769c0d90853","mutatorName":"PublicVisibility","replacement":"protected function setTotalProducts($totalProducts)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":37,"column":5},"end":{"line":37,"column":96}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.028, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::setTotalProducts() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:131\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"99f3abc32b985609efecb48292c73cf4","mutatorName":"PublicVisibility","replacement":"protected function setTotalPrice($totalPrice)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":38,"column":5},"end":{"line":38,"column":84}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\nError: Call to protected method Models\\Order::setTotalPrice() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:132\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","27e8ba2c551cff1a3e7129fa7a38a940","69742414b49277efb4ce0f433c788e09","d274c529f48ebd0c0d2e7e82410e3415","b989a99ca1b325941722866a40278e06"],"killedBy":["69742414b49277efb4ce0f433c788e09"],"testsCompleted":1},{"id":"41a3c57b52e9caddf159efd3c2eb26c6","mutatorName":"PublicVisibility","replacement":"protected function setPaymentStatus($status)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":39,"column":5},"end":{"line":39,"column":82}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 256 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nError: Call to protected method Models\\Order::setPaymentStatus() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:208\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\n\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465","27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"663a397afac6aadf72dec6e2e068a38e","mutatorName":"PublicVisibility","replacement":"protected function setPlacedOn($placedOn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":40,"column":5},"end":{"line":40,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\nError: Call to protected method Models\\Order::setPlacedOn() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:209\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\n\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1.\r\n","coveredBy":["e137814adcd8c47231462a635b04946e","27e8ba2c551cff1a3e7129fa7a38a940"],"killedBy":["27e8ba2c551cff1a3e7129fa7a38a940"],"testsCompleted":2},{"id":"bd4f31186e3e1d7b3d7f755959e14ed6","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":42,"column":5},"end":{"line":42,"column":33}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\nError: Call to protected method Models\\Order::setId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:43\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:24\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","9f4d645aba7ebec46f8fa49817ad0027","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":["0035c38ba38c88bdf071f30dece5b1ed"],"testsCompleted":1},{"id":"bed87732fba8c6591787acf1d621e117","mutatorName":"This","replacement":"return null;","description":"Replaces a `return $this` statement with `return null` instead.","location":{"start":{"line":44,"column":9},"end":{"line":44,"column":22}},"status":"Survived","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n................................... 35 \/ 35 (100%)\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)\r\n","coveredBy":["4b7ef0f4842dd40312696d078881bc1b","ed844fdfee0aca4823e723908e1050c1","e137814adcd8c47231462a635b04946e","0035c38ba38c88bdf071f30dece5b1ed","9f4d645aba7ebec46f8fa49817ad0027","e10152eb56d82638400e2423c572cdc4","9cf07fc703009bc41d2d6794677c2465"],"killedBy":[],"testsCompleted":0}]},"Models\/Product.php":{"language":"php","source":"id; }\r\n public function getName() { return $this->name; }\r\n public function getPrice() { return $this->price; }\r\n public function getImage() { return $this->image; }\r\n\r\n \/\/ Setters\r\n public function setName($name) { $this->name = $name; }\r\n public function setPrice($price) { $this->price = $price; }\r\n public function setImage($image) { $this->image = $image; }\r\n\r\n public function setId($id) {\r\n $this->id = $id;\r\n }\r\n}","mutants":[{"id":"e8a4e47d6ac3c391ddc28a7e5f3d420b","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":11,"column":5},"end":{"line":11,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...........E\nNotice: fwrite(): Write of 955 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\nError: Call to protected method Models\\Product::getId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:266\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\n\nERRORS!\r\nTests: 12, Assertions: 28, Errors: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["1687539f841ed1e27e155d1c2fb94f65"],"testsCompleted":12},{"id":"1a41ff3508b6d56a935400230a65dab3","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":12,"column":5},"end":{"line":12,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:276\n\nERRORS!\r\nTests: 9, Assertions: 32, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":9},{"id":"0ea3d926f52fae86a8c10c3d8e702f3b","mutatorName":"PublicVisibility","replacement":"protected function getPrice()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":13,"column":5},"end":{"line":13,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nError: Call to protected method Models\\Product::getPrice() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:133\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\n\nERRORS!\r\nTests: 3, Assertions: 6, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","cf7867dae1c09fe7077fa87406af264c","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"e53583027ac717d68c3665a3b447be0e","mutatorName":"PublicVisibility","replacement":"protected function getImage()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":14,"column":5},"end":{"line":14,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n..E\nNotice: fwrite(): Write of 335 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\nError: Call to protected method Models\\Product::getImage() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:133\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\n\nERRORS!\r\nTests: 3, Assertions: 6, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65"],"killedBy":["0ef74689b85933c5d3549fbc2e5dea1d"],"testsCompleted":3},{"id":"3ab9a0ff89faa485bc56ec608e903fad","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::setName() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:225\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\n\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":9},{"id":"6765638887b4fda56864d5af924860a0","mutatorName":"PublicVisibility","replacement":"protected function setPrice($price)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 841 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::setPrice() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:226\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\n\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":9},{"id":"e3a188ba795e18b32ab9896ff76aff90","mutatorName":"PublicVisibility","replacement":"protected function setImage($image)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":19,"column":5},"end":{"line":19,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n........E\nNotice: fwrite(): Write of 841 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\nError: Call to protected method Models\\Product::setImage() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:227\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\n\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1.\r\n","coveredBy":["2d96172708d0af33b9c3e772691740b7","cdfbf1ee9d72c63df39b6798ffcd74bd","cf7867dae1c09fe7077fa87406af264c","29b79fb297244e4a16f3feec06d710f8","0ef74689b85933c5d3549fbc2e5dea1d","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01","0dbb68598d76d4d127b823247b0e445a"],"killedBy":["0dbb68598d76d4d127b823247b0e445a"],"testsCompleted":9},{"id":"cca9af17ca1be50e4bb68876371bae35","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":21,"column":5},"end":{"line":21,"column":33}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\nError: Call to protected method Models\\Product::setId() from scope Controllers\\ProductController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:27\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["cdfbf1ee9d72c63df39b6798ffcd74bd","fdc4d9a06f09a8929a91ed6665707728","6f545f29a2bbd15c0e463d582b40e0e6","57253b9d08a8f0a9941004a0ce8690f2","cf7867dae1c09fe7077fa87406af264c","1687539f841ed1e27e155d1c2fb94f65","cb81a55cafc96c5e140058f48b76748b","1e6370b34d1434c9c300fcc4dade9a01"],"killedBy":["1e6370b34d1434c9c300fcc4dade9a01"],"testsCompleted":1}]},"Models\/User.php":{"language":"php","source":"userType = 'user';\r\n }\r\n\r\n \/\/ Getters\r\n public function getId() { return $this->id; }\r\n public function getName() { return $this->name; }\r\n public function getEmail() { return $this->email; }\r\n public function getUserType() { return $this->userType; }\r\n\r\n \/\/ Setters\r\n public function setName($name) { $this->name = $name; }\r\n public function setEmail($email) { $this->email = $email; }\r\n public function setPassword($password) { \r\n $this->password = password_hash($password, PASSWORD_DEFAULT);\r\n }\r\n public function setUserType($userType) { $this->userType = $userType; }\r\n public function setId($id) { \r\n $this->id = $id; \r\n return $this;\r\n }\r\n\r\n public function exists($conn) {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n}","mutants":[{"id":"a812385f0e460e1912e529ecaadb040b","mutatorName":"PublicVisibility","replacement":"protected function getId()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":16,"column":5},"end":{"line":16,"column":50}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n......E\nNotice: fwrite(): Write of 608 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\nError: Call to protected method Models\\User::getId() from scope Controllers\\AdminController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:373\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\n\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1.\r\n","coveredBy":["a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47","7887ca4a2c4a307323ae55b971671a36","cff255228f49b624005b9e8e6a3187d2"],"killedBy":["cff255228f49b624005b9e8e6a3187d2"],"testsCompleted":7},{"id":"d4afac2dee4549bc7057fa6de12bd6d2","mutatorName":"PublicVisibility","replacement":"protected function getName()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":17,"column":5},"end":{"line":17,"column":54}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:310\n\nERRORS!\r\nTests: 10, Assertions: 37, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10},{"id":"c4586d218934bd7438937616f7bef64b","mutatorName":"PublicVisibility","replacement":"protected function getEmail()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":18,"column":5},"end":{"line":18,"column":56}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n...E\nNotice: fwrite(): Write of 404 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\nError: Call to protected method Models\\User::getEmail() from scope Tests\\Unit\\Controllers\\AdminControllerTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\n\nERRORS!\r\nTests: 4, Assertions: 13, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["10855cefec4f27ff428351644efe1527"],"testsCompleted":4},{"id":"d0d78774a901d6117ad999da2be37ba0","mutatorName":"PublicVisibility","replacement":"protected function getUserType()","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":19,"column":5},"end":{"line":19,"column":62}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\nE\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.025, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type\nError: Call to protected method Models\\User::getUserType() from scope Tests\\Unit\\Models\\UserTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:26\n\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1.\r\n","coveredBy":["285178d25eedecfb03dc4c4b6eba6718","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","5f1ac69ed727a6a2093d161091ef2238"],"killedBy":["285178d25eedecfb03dc4c4b6eba6718"],"testsCompleted":1},{"id":"e5b90b3f4e074d77b0ed676214b463d1","mutatorName":"PublicVisibility","replacement":"protected function setName($name)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":22,"column":5},"end":{"line":22,"column":60}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::setName() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:244\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\n\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10},{"id":"02d9ac80d2b13fa177389ece0aeeb701","mutatorName":"PublicVisibility","replacement":"protected function setEmail($email)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":23,"column":5},"end":{"line":23,"column":64}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 914 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::setEmail() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:245\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\n\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10},{"id":"f04b06fb3332a69bbecfe4d2625c948f","mutatorName":"PublicVisibility","replacement":"protected function setPassword($password)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":24,"column":5},"end":{"line":24,"column":46}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.E\nNotice: fwrite(): Write of 249 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado\nError: Call to protected method Models\\User::setPassword() from scope Tests\\Unit\\Models\\UserTest\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:33\n\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1.\r\n","coveredBy":["abcad4aa1b1fdb720f78e696a107cd9d"],"killedBy":["abcad4aa1b1fdb720f78e696a107cd9d"],"testsCompleted":2},{"id":"636131679d0cc337007876fe98ffbb52","mutatorName":"PublicVisibility","replacement":"protected function setUserType($userType)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":27,"column":5},"end":{"line":27,"column":76}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\n\n.........E\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 error:\n\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\nError: Call to protected method Models\\User::setUserType() from scope Controllers\\OrderController\n\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:246\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\n\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1.\r\n","coveredBy":["10855cefec4f27ff428351644efe1527","aca810d1d7530667d800dd6115dd2020","cf7f861e585d3046cc970897756c7229","4e5d456bcd3f0f480afe371d6ab58a3a","c6a72142a437ffdb72dd509a3961171c","5562fefd1e6267f1330a8be9c24c0c1e","7e8c90fdba931569ce4b61319939fb43","74d98ff831c11e5975e82c1f78463f05","1648e182f0dec8698cc3c000b7c001fe","5f1ac69ed727a6a2093d161091ef2238","1884bc4f1d1fef63116444d66c172e6b"],"killedBy":["aca810d1d7530667d800dd6115dd2020"],"testsCompleted":10},{"id":"9e85f149773f6c3b40b40c2a55b9a727","mutatorName":"PublicVisibility","replacement":"protected function setId($id)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":28,"column":5},"end":{"line":28,"column":34}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47","7887ca4a2c4a307323ae55b971671a36","cff255228f49b624005b9e8e6a3187d2","10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"6a1ef1a1f72f9cc8bf052458a1abe2ae","mutatorName":"This","replacement":"return null;","description":"Replaces a `return $this` statement with `return null` instead.","location":{"start":{"line":30,"column":9},"end":{"line":30,"column":22}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47","7887ca4a2c4a307323ae55b971671a36","cff255228f49b624005b9e8e6a3187d2","10855cefec4f27ff428351644efe1527"],"killedBy":[],"testsCompleted":0},{"id":"76b4ec022036eeb643f458399debb2fd","mutatorName":"PublicVisibility","replacement":"protected function exists($conn)","description":"Replaces the `public` method visibility keyword with `protected`.","location":{"start":{"line":33,"column":5},"end":{"line":33,"column":36}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"f367cbf7426f6634d93a91aba2776f0b","mutatorName":"ArrayItemRemoval","replacement":"$stmt->execute([]);","description":"Removes an element of an array literal. For example:\n\n```php\n$x = [0, 1, 2];\n```\n\nWill be mutated to:\n\n```php\n$x = [1, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 2];\n```\n\nAnd:\n\n```php\n$x = [0, 1];\n```\n\nWhich elements it removes or how many elements it will attempt to remove will depend on its\nconfiguration.\n","location":{"start":{"line":35,"column":9},"end":{"line":35,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"fc5ecaa69bccd594773448c94ea02af5","mutatorName":"MethodCallRemoval","replacement":"","description":"Removes the method call.","location":{"start":{"line":35,"column":9},"end":{"line":35,"column":37}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"e724cbe39833a8628e1bd0402fac1c8d","mutatorName":"GreaterThan","replacement":"return $stmt->rowCount() >= 0;","description":"Replaces a greater-than operator (`>`) with the greater-than-or-equal-to operator (`>=`).","location":{"start":{"line":36,"column":9},"end":{"line":36,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0},{"id":"834309f2522e5360ba85b3cb0d2ca648","mutatorName":"GreaterThanNegotiation","replacement":"return $stmt->rowCount() <= 0;","description":"Replaces a greater-than operator (`>`) with the less-than-or-equal-to operator (`<=`).","location":{"start":{"line":36,"column":9},"end":{"line":36,"column":38}},"status":"Killed","statusReason":"\nWarning: Module \"openssl\" is already loaded in Unknown on line 0\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found\r\n","coveredBy":["5088f3b11ad49667e4f9a7b896a88ede","a2abfd90bc3ac1aaedbe1b522cdb7564","ecf5c7e40cfc13af5d0ff47e2cb25e47"],"killedBy":[],"testsCompleted":0}]}},"testFiles":{"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php":{"tests":[{"id":"a76b01946547645afdff37bedb7a60d8","name":"Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php":{"tests":[{"id":"0035c38ba38c88bdf071f30dece5b1ed","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData"},{"id":"4b7ef0f4842dd40312696d078881bc1b","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings"},{"id":"ed844fdfee0aca4823e723908e1050c1","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted"},{"id":"29b79fb297244e4a16f3feec06d710f8","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName"},{"id":"0ef74689b85933c5d3549fbc2e5dea1d","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully"},{"id":"09d8bcdc9cfda619b9c89a29648d2d8e","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct"},{"id":"da270c190fd61906ead367a1ea0887d7","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension"},{"id":"4a940269ad09ef1eaa1ca8bf8babb532","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath"},{"id":"d736e3db7bd2dbf25459d31155b47535","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDelete"},{"id":"1687539f841ed1e27e155d1c2fb94f65","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct"},{"id":"fdc4d9a06f09a8929a91ed6665707728","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError"},{"id":"6f545f29a2bbd15c0e463d582b40e0e6","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithoutImage"},{"id":"57253b9d08a8f0a9941004a0ce8690f2","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage"},{"id":"cf7867dae1c09fe7077fa87406af264c","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts"},{"id":"e137814adcd8c47231462a635b04946e","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders"},{"id":"e10152eb56d82638400e2423c572cdc4","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatusDatabaseError"},{"id":"9cf07fc703009bc41d2d6794677c2465","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus"},{"id":"9f4d645aba7ebec46f8fa49817ad0027","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder"},{"id":"10855cefec4f27ff428351644efe1527","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers"},{"id":"cff255228f49b624005b9e8e6a3187d2","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser"},{"id":"36243924380b2e3a203435fb9bdce1d1","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages"},{"id":"111d21c767467e138a3e41568fbcceab","name":"Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\AdminControllerMutationTest.php":{"tests":[{"id":"2d96172708d0af33b9c3e772691740b7","name":"Tests\\Mutation\\AdminControllerMutationTest::testAddProductMutation"},{"id":"bc679a7bfa1a66d938d5ff57e1539d14","name":"Tests\\Mutation\\AdminControllerMutationTest::testDeleteProductMutation"},{"id":"cdfbf1ee9d72c63df39b6798ffcd74bd","name":"Tests\\Mutation\\AdminControllerMutationTest::testUpdateProductMutation"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php":{"tests":[{"id":"5088f3b11ad49667e4f9a7b896a88ede","name":"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithInvalidUserId"},{"id":"b488b34d4881115bec02ef8105e30716","name":"Tests\\Mutation\\ContactControllerMutationTest::testSendMessageMutationWithMissingFields"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php":{"tests":[{"id":"5aeab43d6bb5e254f77e2aa5dac28edb","name":"Tests\\Unit\\Controllers\\ContactControllerTest::crear_usuario_retorna_instancia_user"},{"id":"68e73fbb4670258440901c3a46e2064d","name":"Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message"},{"id":"d59917b2d5528ca6063952ee4f1d097b","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_user_id"},{"id":"dadb1321b7b0db79872fdfdbe6115493","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar"},{"id":"1a5c37673a34ba1e37ac2923b430a4e6","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado"},{"id":"b93f5bfed89d4ed88cd4c8765ceac045","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_campos_faltantes"},{"id":"c7648c8a27ed50c48a0d2328c2890535","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_maneja_error_en_save"},{"id":"76926558c21488fe35e209f0ecda409e","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion"},{"id":"966624d19ce2dba3bed3eccf1c0f956f","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_usuario_no_encontrado"},{"id":"aa989a99b189876d061fe9ba83f42bce","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters"},{"id":"9ebb033692c3de0faab3cd111369f928","name":"Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php":{"tests":[{"id":"ceb6936c11cf19bb44e528fa327f0416","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos"},{"id":"40ff0078972e38dca8cfb4be5e49a3b0","name":"Tests\\Unit\\Controllers\\OrderControllerTest::actualizar_estado_pago"},{"id":"452ca6af2bdb570f2ff036e996e62a49","name":"Tests\\Unit\\Controllers\\OrderControllerTest::eliminar_pedido"},{"id":"b989a99ca1b325941722866a40278e06","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos"},{"id":"69742414b49277efb4ce0f433c788e09","name":"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido"},{"id":"9b1d437f68a23ef8f0c60f232232f51c","name":"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_carrito_vacio"},{"id":"d274c529f48ebd0c0d2e7e82410e3415","name":"Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado"},{"id":"7a701a7b1ab59a11ed7dcb7f27545ae6","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido"},{"id":"27e8ba2c551cff1a3e7129fa7a38a940","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario"},{"id":"116e55b7e31c4b7eb431eadb6fd89108","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_productos"},{"id":"0dbb68598d76d4d127b823247b0e445a","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos"},{"id":"b388534ee189eeb5ea1ebdd33ff1fb04","name":"Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_obtener_todos_usuarios"},{"id":"aca810d1d7530667d800dd6115dd2020","name":"Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php":{"tests":[{"id":"ac9ac5f42f33e350edbcf6e51247ed95","name":"Tests\\Mutation\\OrderControllerMutationTest::testUpdatePaymentStatusMutation"},{"id":"9112c9fc2d730bc2c02af9b6785500ea","name":"Tests\\Mutation\\OrderControllerMutationTest::testDeleteOrderMutation"},{"id":"17fc22fdee4bdc93146edb702b18eb90","name":"Tests\\Mutation\\OrderControllerMutationTest::testCreateOrderMutationWithEmptyCart"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php":{"tests":[{"id":"feb6d707c4d8182bd8ec66df03f90917","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_productos_recientes"},{"id":"1e6370b34d1434c9c300fcc4dade9a01","name":"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes"},{"id":"6fe2e83f565ec7dff367868cae77e679","name":"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_producto_duplicado_al_carrito"},{"id":"21b277a20d75495834b915634005099f","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito"},{"id":"496122c302addcbe11f203caffa7d24f","name":"Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito"},{"id":"96cb93ace2fec2f94dda2e1aac950bbc","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_todos_productos"},{"id":"cb81a55cafc96c5e140058f48b76748b","name":"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos"},{"id":"5144a3795216d9768bcf2e1b0de52d7c","name":"Tests\\Unit\\Controllers\\ProductControllerTest::verificar_carrito_vacio"},{"id":"47942d6a996427c3c1cec9efff6173b2","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_obtener_items_carrito"},{"id":"242f299f525da768f9961477f538fcf7","name":"Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito"},{"id":"861ce129fc3196e3f58b8d7dc15e77f8","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_actualizar_cantidad"},{"id":"fc8f4ab810696c7119210820c8dcb994","name":"Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso"},{"id":"8b777577a59cbaa568701bb5fa606fc0","name":"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso"},{"id":"8d3a5cdebb924a18bbd6039914683cec","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_item_carrito"},{"id":"9079b2b01975467bd588ac0635613e00","name":"Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito"},{"id":"533c884852c9465706da5a94e08ac4b2","name":"Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php":{"tests":[{"id":"dc7b02abddb2408e22973baf42d4b091","name":"Tests\\Mutation\\ProductControllerMutationTest::testAddToCartMutationWithDuplicate"},{"id":"dbc96c03f3b64a74b10909e936648484","name":"Tests\\Mutation\\ProductControllerMutationTest::testUpdateCartQuantityMutation"},{"id":"90d2b1363c2387d208e61551e5d81906","name":"Tests\\Mutation\\ProductControllerMutationTest::testDeleteCartItemMutation"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php":{"tests":[{"id":"119dcc727a6c5c37089ce369397e3936","name":"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_no_hay_resultados"},{"id":"38f507e5499b7d283bd2d73a0e5dab72","name":"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados"},{"id":"9499b5d588e5718df0bbb5d28d1d7337","name":"Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_array_vacio_cuando_hay_excepcion"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php":{"tests":[{"id":"4e5d456bcd3f0f480afe371d6ab58a3a","name":"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse"},{"id":"c6a72142a437ffdb72dd509a3961171c","name":"Tests\\Unit\\Controllers\\UserControllerTest::registro_con_tipo_usuario_personalizado"},{"id":"c5f619a697779b293907d101b23e2cc5","name":"Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto"},{"id":"7e8c90fdba931569ce4b61319939fb43","name":"Tests\\Unit\\Controllers\\UserControllerTest::verificar_hash_password"},{"id":"74d98ff831c11e5975e82c1f78463f05","name":"Tests\\Unit\\Controllers\\UserControllerTest::registro_exitoso_sin_tipo_usuario"},{"id":"5f1ac69ed727a6a2093d161091ef2238","name":"Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register"},{"id":"1f53110b52fbcb82fad3d83ce886911f","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_password_incorrecto"},{"id":"e90d3c5d6475a8b9876cd1a2fd342fc2","name":"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_correcto"},{"id":"c0b609be3f46cabd11f9479c3867ba10","name":"Tests\\Unit\\Controllers\\UserControllerTest::verifica_password_incorrecto"},{"id":"7e243c64fb424b58831479362b095622","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_nombre_en_sesion"},{"id":"f68eb8b986d9fc309ed29c287efd52cb","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_password_incorrecto"},{"id":"2c9e012a8ef82162dc733a7d5ed147cb","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_exitoso_con_admin"},{"id":"bc66590a599c81f251afe7f022704124","name":"Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion"},{"id":"7a41cc8095f8763e256eeeabc2964148","name":"Tests\\Unit\\Controllers\\UserControllerTest::login_guarda_tipo_usuario_en_sesion"},{"id":"cf7f861e585d3046cc970897756c7229","name":"Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente"},{"id":"5562fefd1e6267f1330a8be9c24c0c1e","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_email_existente"},{"id":"1648e182f0dec8698cc3c000b7c001fe","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_register_con_error_db"},{"id":"1884bc4f1d1fef63116444d66c172e6b","name":"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro"},{"id":"88913d5fb1ca58b323af46d3e38f8b37","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_error_db"},{"id":"377db5af9ac5ffe374c7f038544ba613","name":"Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas"},{"id":"dc1973acbaca0a28a598effc18237ad0","name":"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login"},{"id":"f94ca319ab2dfc219b33dcd743cfeb5f","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_login_con_credenciales_invalidas"},{"id":"a3214e814150e4694e5bde76166b4a2b","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_usuario_no_existe"},{"id":"6511508b57f48da46af4c82281794cb0","name":"Tests\\Unit\\Controllers\\UserControllerTest::test_getUserById_con_error_db"},{"id":"baeba2b0443c9006dae99054a84bf92d","name":"Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_al_obtener_usuario"},{"id":"ebc491f7be9fdad3965e5ccdf30566c6","name":"Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id"},{"id":"62b48a5e15de8d584745b990f5316ddb","name":"Tests\\Unit\\Controllers\\UserControllerTest::obtener_usuario_inexistente"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Exceptions\\DatabaseExceptionTest.php":{"tests":[{"id":"14c8f43f9e245c169de43a060ab0f2de","name":"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::hereda_de_exception"},{"id":"bdebf4104aab33e53ad818316cae31d9","name":"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_sin_parametros"},{"id":"9a69dda033b5b96b3a4d273cef8d5e4d","name":"Tests\\Unit\\Exceptions\\DatabaseExceptionTest::puede_crear_excepcion_con_parametros"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php":{"tests":[{"id":"526a8af9ac30be501c7f4b37124d576f","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id"},{"id":"982c4d44a4015074431dc655f61bf9c9","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id"},{"id":"2b1642fa5d7b37210b33ee2a94697390","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name"},{"id":"19542864ba4ef81044cd17038a6e8c59","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email"},{"id":"acf82b784e1fde7256a6c27e70355a65","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number"},{"id":"83c78b91f60c0ee0e7c5af4cda4ca08c","name":"Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message"},{"id":"4813abd1aac2f55ae34e6218d3266a72","name":"Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje"},{"id":"09cbcccec0a12bf6ed83725861831d3b","name":"Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia"},{"id":"9fac10250403152dbfd443e6d82c8728","name":"Tests\\Unit\\Models\\MessageTest::maneja_error_al_guardar"}]},"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php":{"tests":[{"id":"a2abfd90bc3ac1aaedbe1b522cdb7564","name":"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_false_cuando_no_existe"},{"id":"ecf5c7e40cfc13af5d0ff47e2cb25e47","name":"Tests\\Unit\\Models\\UserTest::verifica_exists_retorna_true_cuando_existe"},{"id":"7887ca4a2c4a307323ae55b971671a36","name":"Tests\\Unit\\Models\\UserTest::verifica_setId_retorna_instancia"},{"id":"285178d25eedecfb03dc4c4b6eba6718","name":"Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type"},{"id":"abcad4aa1b1fdb720f78e696a107cd9d","name":"Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado"}]}},"framework":{"name":"Infection","branding":{"homepageUrl":"https:\/\/infection.github.io\/","imageUrl":"https:\/\/infection.github.io\/images\/logo.png"}}} ; diff --git a/reports/mutations/infection.json b/reports/mutations/infection.json index a5c4dc88..78d013e5 100644 --- a/reports/mutations/infection.json +++ b/reports/mutations/infection.json @@ -1 +1 @@ -{"stats":{"totalMutantsCount":541,"killedCount":350,"notCoveredCount":0,"escapedCount":180,"errorCount":0,"syntaxErrorCount":0,"skippedCount":0,"ignoredCount":0,"timeOutCount":11,"msi":66.73,"mutationCodeCoverage":100,"coveredCodeMsi":66.73},"escaped":[{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n \n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function getTotalPendings()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n- $stmt->execute();\r\n+ \r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setId($row['id']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n \n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function getTotalCompleted()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n- $stmt->execute();\r\n+ \r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":55},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setId($row['id']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":65},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n private function getProductsCount()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $query = \"SELECT COUNT(*) as count FROM `products`\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n private function getUsersCount()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":79},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n private function getAdminsCount()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":86},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n private function getTotalAccounts()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":93},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $query = \"SELECT COUNT(*) as count FROM `users`\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n private function getMessagesCount()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":100},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $query = \"SELECT COUNT(*) as count FROM `message`\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\r\n }\r\n private function handleDatabaseError($e)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2274 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log($e->getMessage() . \"Error en la base de datos: \");\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError($e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en la base de datos: \");\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n public function addProduct($postData, $files)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log($e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError($e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n public function addProduct($postData, $files)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \");\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError($e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ error_log(\"Error en la base de datos: \");\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n public function addProduct($postData, $files)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n \n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError($e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ \r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n public function addProduct($postData, $files)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) && !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":172},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n- if (empty($imageName) || !is_string($imageName)) {\r\n+ if (empty($imageName) && !is_string($imageName)) {\r\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\r\n }\r\n \/\/ Obtener y validar la extensi\u00f3n","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"UnwrapStrToLower","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = pathinfo($imageName, PATHINFO_EXTENSION);\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":177},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\r\n }\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n- $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\r\n+ $extension = pathinfo($imageName, PATHINFO_EXTENSION);\r\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n throw new \\Exception('Tipo de archivo no permitido');\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":184},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n- $stmt->execute([$imageName]);\r\n+ $stmt->execute([]);\r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n \n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":184},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n- $stmt->execute([$imageName]);\r\n+ \r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return $imageName . self::UPLOAD_PATH;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":189},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n- return self::UPLOAD_PATH . $imageName;\r\n+ return $imageName . self::UPLOAD_PATH;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":189},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n- return self::UPLOAD_PATH . $imageName;\r\n+ return $imageName;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en getSecureImagePath: \");\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":191},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en getSecureImagePath: \");\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":191},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \");\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":191},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n+ error_log(\"Error en getSecureImagePath: \");\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n \n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":191},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n+ \r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return true;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":209},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$imageName]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if (!$result) {\r\n- return false;\r\n+ return true;\r\n }\r\n \/\/ Construir y validar la ruta\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.060, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":284},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setId($row['id']);\r\n+ \r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n \n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":287},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n- $product->setImage($row['image']);\r\n+ \r\n $products[] = $product;\r\n }\r\n return $products;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n \n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":295},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function getAllOrders()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n- $stmt->execute();\r\n+ \r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":299},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setId($row['id']);\r\n+ \r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n \n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":300},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n- $order->setUserId($row['user_id']);\r\n+ \r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n \n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":301},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n- $order->setPlacedOn($row['placed_on']);\r\n+ \r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n \n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":303},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n- $order->setNumber($row['number']);\r\n+ \r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n \n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":304},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n- $order->setEmail($row['email']);\r\n+ \r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n \n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":305},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n- $order->setAddress($row['address']);\r\n+ \r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n \n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":306},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n- $order->setTotalProducts($row['total_products']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);\r\n $order->setPaymentStatus($row['payment_status']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n \n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":308},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $order->setMethod($row['method']);\r\n+ \r\n $order->setPaymentStatus($row['payment_status']);\r\n $orders[] = $order;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.057, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n \n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":309},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);\r\n- $order->setPaymentStatus($row['payment_status']);\r\n+ \r\n $orders[] = $order;\r\n }\r\n return $orders;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n \n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":318},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $order = new Order();\r\n- $order->setId($orderId);\r\n+ \r\n $order->setPaymentStatus($status);\r\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n \n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":319},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $order = new Order();\r\n $order->setId($orderId);\r\n- $order->setPaymentStatus($status);\r\n+ \r\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\r\n } catch (\\PDOException $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2290 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.060, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":322},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setId($orderId);\r\n $order->setPaymentStatus($status);\r\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\r\n- return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\r\n+ return $stmt->execute([$order->getId()]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.055, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n \n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":332},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $order = new Order();\r\n- $order->setId($orderId);\r\n+ \r\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\r\n return $stmt->execute([$order->getId()]);\r\n } catch (\\PDOException $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":335},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($orderId);\r\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\r\n- return $stmt->execute([$order->getId()]);\r\n+ return $stmt->execute([]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.057, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n \n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":345},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n- $stmt->execute();\r\n+ \r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n \n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":350},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n- $user->setId($row['id']);\r\n+ \r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n \n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":353},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n- $user->setUserType($row['user_type']);\r\n+ \r\n $users[] = $user;\r\n }\r\n return $users;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2285 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n \n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":366},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $user = new User();\r\n- $user->setId($userId);\r\n+ \r\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\r\n return $stmt->execute([$user->getId()]);\r\n } catch (\\PDOException $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2286 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":369},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setId($userId);\r\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\r\n- return $stmt->execute([$user->getId()]);\r\n+ return $stmt->execute([]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n \n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":382},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $messages = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $message = new Message();\r\n- $message->setId($row['id']);\r\n+ \r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n \n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":383},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n- $message->setUserId($row['user_id']);\r\n+ \r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n \n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":385},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n- $message->setName($row['name']);\r\n+ \r\n $message->setEmail($row['email']);\r\n $message->setNumber($row['number']);\r\n $messages[] = $message;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n \n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":387},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);\r\n- $message->setNumber($row['number']);\r\n+ \r\n $messages[] = $message;\r\n }\r\n return $messages;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":401},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM `message` WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- return $stmt->execute([$messageId]);\r\n+ return $stmt->execute([]);\r\n } catch (\\PDOException $e) {\r\n $this->handleDatabaseError($e);\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2282 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log($userData['user_id'] . \"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ error_log($userData['user_id'] . \"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1070 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log($userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ error_log($userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n- \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ \r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al enviar mensaje: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al enviar mensaje: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ error_log(\"Error al enviar mensaje: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1070 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => $e->getMessage() . 'Error al enviar mensaje: '];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => false, 'message' => $e->getMessage() . 'Error al enviar mensaje: '];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: '];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => false, 'message' => 'Error al enviar mensaje: '];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n- $this->handleDatabaseError($e);\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n \n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n- $order->setName($row['name']);\r\n+ \r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n \n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":74},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n- $order->setEmail($row['email']);\r\n+ \r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n \n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":75},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n- $order->setMethod($row['method']);\r\n+ \r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n \n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":76},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n- $order->setAddress($row['address']);\r\n+ \r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $orders[] = $order;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n \n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":77},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n- $order->setTotalProducts($row['total_products']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $orders[] = $order;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n \n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":78},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $orders[] = $order;\r\n }\r\n return $orders;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = -1;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":104},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n \/\/ Calcular total y preparar lista de productos\r\n- $cartTotal = 0;\r\n+ $cartTotal = -1;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach (array() as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Calcular total y preparar lista de productos\r\n $cartTotal = 0;\r\n $products = [];\r\n- foreach ($cartItems as $item) {\r\n+ foreach (array() as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = ' (' . $item['name'] . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = ' (' . $item['name'] . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = ' (' . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . $item['quantity'] . ' (' . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . $item['quantity'] . ' (' . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . ' (' . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . ')' . $item['quantity'];\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . ' (' . ')' . $item['quantity'];\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'];\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":107},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . ' (' . $item['quantity'];\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Multiplication","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] \/ $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":108},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n- $cartTotal += $item['price'] * $item['quantity'];\r\n+ $cartTotal += $item['price'] \/ $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Assignment","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal = $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":108},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n- $cartTotal += $item['price'] * $item['quantity'];\r\n+ $cartTotal = $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"PlusEqual","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal -= $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":108},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n- $cartTotal += $item['price'] * $item['quantity'];\r\n+ $cartTotal -= $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = $userData['flat'] . 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = $userData['flat'] . 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . ', ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . ', ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1349 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1345 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - ';\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - ';\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ';\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ';\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":120},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n- \/\/ Establecer valores adicionales en el objeto Order\r\n- $order->setAddress($address);\r\n+ \r\n $order->setTotalProducts($totalProducts);\r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1345 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n \n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":121},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n- $order->setTotalProducts($totalProducts);\r\n+ \r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n \n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":122},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);\r\n- $order->setTotalPrice($cartTotal);\r\n+ \r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n- $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n+ $stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":150},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n- $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n+ $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al crear orden: \");\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":167},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al crear orden: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al crear orden: \");\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1349 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":167},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al crear orden: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \");\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":167},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al crear orden: \" . $e->getMessage());\r\n+ error_log(\"Error al crear orden: \");\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":167},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al crear orden: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":180},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function clearCart($userId)\r\n {\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n }\r\n public function getUserOrders($userId)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n \n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":191},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n- $order->setName($row['name']);\r\n+ \r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n \n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":192},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n- $order->setNumber($row['number']);\r\n+ \r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n \n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":193},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n- $order->setEmail($row['email']);\r\n+ \r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n \n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":194},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n- $order->setMethod($row['method']);\r\n+ \r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n \n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":195},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n- $order->setAddress($row['address']);\r\n+ \r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1362 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n \n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":196},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n- $order->setTotalProducts($row['total_products']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $order->setPlacedOn($row['placed_on']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.074, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n \n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":197},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $order->setPaymentStatus($row['payment_status']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $orders[] = $order;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.073, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n \n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":198},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $order->setPaymentStatus($row['payment_status']);\r\n+ \r\n $order->setPlacedOn($row['placed_on']);\r\n $orders[] = $order;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.073, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n \n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":199},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n- $order->setPlacedOn($row['placed_on']);\r\n+ \r\n $orders[] = $order;\r\n }\r\n return $orders;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1362 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":216},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n \n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n- $product->setImage($row['image']);\r\n+ \r\n $products[] = $product;\r\n }\r\n return $products;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":222},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- $this->handleDatabaseError($e);\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n \n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":235},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n $user->setName($row['name']);\r\n- $user->setEmail($row['email']);\r\n+ \r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n \n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":236},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n- $user->setUserType($row['user_type']);\r\n+ \r\n $users[] = $user;\r\n }\r\n return $users;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1346 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":241},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $users;\r\n } catch (\\Exception $e) {\r\n- $this->handleDatabaseError($e);\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log($e->getMessage() . \"Error en la base de datos: \");\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":247},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError(\\Exception $e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en la base de datos: \");\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1341 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log($e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":247},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError(\\Exception $e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1342 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \");\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":247},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError(\\Exception $e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ error_log(\"Error en la base de datos: \");\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1338 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n \n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":247},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function handleDatabaseError(\\Exception $e)\r\n {\r\n- error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n+ \r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1330 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nOK (16 tests, 61 assertions)"},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 5)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getLatestProducts($limit = 6)\r\n+ public function getLatestProducts($limit = 5)\r\n {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"IncrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 7)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getLatestProducts($limit = 6)\r\n+ public function getLatestProducts($limit = 7)\r\n {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n \n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n+ \r\n $stmt->execute();\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setId($row['id']);\r\n+ \r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1458 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":29},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1454 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n \n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n- $product->setImage($row['image']);\r\n+ \r\n $products[] = $product;\r\n }\r\n return $products;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener productos: \");\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \");\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1462 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1454 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n+ $stmt->execute([$cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al a\u00f1adir al carrito: \");\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al a\u00f1adir al carrito: \");\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \");\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ error_log(\"Error al a\u00f1adir al carrito: \");\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1458 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.062, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":86},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setId($row['id']);\r\n+ \r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":88},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n \n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":89},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n- $product->setImage($row['image']);\r\n+ \r\n $products[] = $product;\r\n }\r\n return $products;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener todos los productos: \");\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener todos los productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \");\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener todos los productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener items del carrito: \");\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener items del carrito: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \");\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener items del carrito: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al eliminar todos los items: \");\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al eliminar todos los items: \");\r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1434 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \");\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ error_log(\"Error al eliminar todos los items: \");\r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1438 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n \n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ \r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n \n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $user = new User();\r\n- $user->setName($userData['name']);\r\n+ \r\n $user->setEmail($userData['email']);\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.602, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n \n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":26},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n- $user->setEmail($userData['email']);\r\n+ \r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2926 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.635, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"Coalesce","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType('user' ?? $userData['user_type']);\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n $user->setEmail($userData['email']);\r\n- $user->setUserType($userData['user_type'] ?? 'user');\r\n+ $user->setUserType('user' ?? $userData['user_type']);\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2916 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.595, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n \n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n $user->setEmail($userData['email']);\r\n- $user->setUserType($userData['user_type'] ?? 'user');\r\n+ \r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.531, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n- $stmt->execute([$user->getEmail()]);\r\n+ $stmt->execute([]);\r\n if ($stmt->fetch()) {\r\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.670, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n \n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n- $stmt->execute([$user->getEmail()]);\r\n+ \r\n if ($stmt->fetch()) {\r\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2917 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:04.035, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en registro: \");\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en registro: \");\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2912 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.399, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2910 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.394, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \");\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ error_log(\"Error en registro: \");\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2920 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.430, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2905 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.415, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en login: \");\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en login: \");\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2922 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.622, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2940 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.659, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \");\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ error_log(\"Error en login: \");\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2908 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.637, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2923 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.675, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener usuario: \");\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener usuario: \");\r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2920 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.757, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2922 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.736, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \");\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener usuario: \");\r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2917 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.689, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n \n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ \r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................. 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2912 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.681, Memory: 8.00 MB\r\n\r\nOK (34 tests, 63 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);\r\n- $stmt->execute([$this->userId, $this->message]);\r\n+ $stmt->execute([$this->message]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n public function save($conn)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......... 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 675 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $conn->prepare($sql);\r\n- return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\r\n+ return $stmt->execute([$this->name, $this->email, $this->number, $this->message]);\r\n }\r\n public function setId($id)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......... 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 676 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)"},{"mutator":{"mutatorName":"This","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return null;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function setId($id)\r\n {\r\n $this->id = $id;\r\n- return $this;\r\n+ return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............................. 30 \/ 30 (100%)\r\nNotice: fwrite(): Write of 2278 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (30 tests, 57 assertions)"}],"timeouted":[{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":13},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $user;\r\n private $password;\r\n private $database;\r\n- public function __construct(bool $useEnv = true)\r\n+ public function __construct(bool $useEnv = false)\r\n {\r\n if (!$useEnv) {\r\n $this->setDefaultCredentials();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ? '123456' : getenv('DB_PASSWORD');\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n- $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n+ $this->password = getenv('DB_PASSWORD') ? '123456' : getenv('DB_PASSWORD');\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n }\r\n public function setCredentials(string $host, string $user, string $password, string $database) : void","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ? 'tienda_bd' : getenv('DB_NAME');\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n- $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n+ $this->database = getenv('DB_NAME') ? 'tienda_bd' : getenv('DB_NAME');\r\n }\r\n public function setCredentials(string $host, string $user, string $password, string $database) : void\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array());\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":57},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function connect()\r\n {\r\n try {\r\n- $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\r\n+ $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array());\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log($e->getMessage() . \"Error de conexi\u00f3n: \");\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error de conexi\u00f3n: \");\r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log($e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \");\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ error_log(\"Error de conexi\u00f3n: \");\r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n \n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ \r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException($e->getMessage() . \"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":64},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ throw new DatabaseException($e->getMessage() . \"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException($e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":64},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ throw new DatabaseException($e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":64},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"}],"killed":[{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $database;\r\n public function __construct(bool $useEnv = true)\r\n {\r\n- if (!$useEnv) {\r\n+ if ($useEnv) {\r\n $this->setDefaultCredentials();\r\n return;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.012, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\r\nfopen(C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\.env): Failed to open stream: Permission denied\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php:113\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php:20\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:14\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function __construct(bool $useEnv = true)\r\n {\r\n if (!$useEnv) {\r\n- $this->setDefaultCredentials();\r\n+ \r\n return;\r\n }\r\n $envPath = __DIR__ . '\/..\/..\/.env';","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.719, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\r\nFailed asserting that null matches expected 'test_host'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1."},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ? 'db' : getenv('DB_HOST');\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function setDefaultCredentials() : void\r\n {\r\n- $this->host = getenv('DB_HOST') ?: 'db';\r\n+ $this->host = getenv('DB_HOST') ? 'db' : getenv('DB_HOST');\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.704, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'test_host'\r\n+'db'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1."},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ? 'root' : getenv('DB_USER');\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function setDefaultCredentials() : void\r\n {\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n- $this->user = getenv('DB_USER') ?: 'root';\r\n+ $this->user = getenv('DB_USER') ? 'root' : getenv('DB_USER');\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 398 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.717, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_valores_por_defecto_cuando_no_hay_env\r\nFailed asserting that false matches expected 'root'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:58\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n protected function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->password = $password;\r\n $this->database = $database;\r\n }\r\n- public function connect()\r\n+ protected function connect()\r\n {\r\n try {\r\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.019, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\r\nFailed asserting that exception of type \"Error\" matches expected exception \"Exceptions\\DatabaseException\". Message was: \"Call to protected method Config\\Database::connect() from scope Tests\\Unit\\Config\\DatabaseTest\" at\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:18\r\n.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":63},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.717, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\r\nFailed asserting that exception of type \"Exceptions\\DatabaseException\" is thrown.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":20},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getDashboardData()\r\n+ protected function getDashboardData()\r\n {\r\n $data = [];\r\n \/\/ Obtener total pendientes","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\r\nError: Call to protected method Controllers\\AdminController::getDashboardData() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = -1;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n $stmt->execute();\r\n- $total = 0;\r\n+ $total = -1;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 249.0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach (array() as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n $stmt->execute();\r\n $total = 0;\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n \n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":43},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"Assignment","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total = $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $total += $order->getTotalPrice();\r\n+ $total = $order->getTotalPrice();\r\n }\r\n return $total;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 150.0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"PlusEqual","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total -= $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $total += $order->getTotalPrice();\r\n+ $total -= $order->getTotalPrice();\r\n }\r\n return $total;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that -250.0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = -1;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":52},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n $stmt->execute();\r\n- $total = 0;\r\n+ $total = -1;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that 499.0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach (array() as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":53},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n $stmt->execute();\r\n $total = 0;\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that 0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n \n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":56},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that 0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"Assignment","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total = $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":57},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $total += $order->getTotalPrice();\r\n+ $total = $order->getTotalPrice();\r\n }\r\n return $total;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that 300.0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"PlusEqual","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total -= $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":57},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $total += $order->getTotalPrice();\r\n+ $total -= $order->getTotalPrice();\r\n }\r\n return $total;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1186 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that -500.0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function handleDatabaseError($e)\r\n {\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n- throw new \\Exception(\"Error al procesar la solicitud\");\r\n+ new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n public function addProduct($postData, $files)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............F\r\nNotice: fwrite(): Write of 1047 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleDatabaseError\r\nFailed asserting that exception of type \"Exception\" is thrown.\r\n\r\nFAILURES!\r\nTests: 13, Assertions: 34, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n protected function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":109},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n- public function addProduct($postData, $files)\r\n+ protected function addProduct($postData, $files)\r\n {\r\n try {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.E\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nError: Call to protected method Controllers\\AdminController::addProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n \n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":112},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $product = new Product();\r\n- $product->setName($postData['name']);\r\n+ \r\n $product->setPrice($postData['price']);\r\n $product->setImage($files['image']['name']);\r\n \/\/ Verificar si el producto ya existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2300 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n \n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $product = new Product();\r\n $product->setName($postData['name']);\r\n- $product->setPrice($postData['price']);\r\n+ \r\n $product->setImage($files['image']['name']);\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n \n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":114},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setName($postData['name']);\r\n $product->setPrice($postData['price']);\r\n- $product->setImage($files['image']['name']);\r\n+ \r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setImage($files['image']['name']);\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n- $stmt->execute([$product->getName()]);\r\n+ $stmt->execute([]);\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n \n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setImage($files['image']['name']);\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n- $stmt->execute([$product->getName()]);\r\n+ \r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2300 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() >= 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":120},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() >= 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.F\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() <= 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":120},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() <= 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.F\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => true, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":121},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya existe'];\r\n+ return ['success' => true, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........................F\r\nNotice: fwrite(): Write of 2191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:573\r\n\r\nFAILURES!\r\nTests: 28, Assertions: 53, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":121},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya existe'];\r\n+ return ['message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........................E\r\nNotice: fwrite(): Write of 2199 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductWithExistingName\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:573\r\n\r\nERRORS!\r\nTests: 28, Assertions: 52, Errors: 1."},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] >= 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":124},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n- if ($files['image']['size'] > 2000000) {\r\n+ if ($files['image']['size'] >= 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] <= 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":124},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n- if ($files['image']['size'] > 2000000) {\r\n+ if ($files['image']['size'] <= 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.F\r\nNotice: fwrite(): Write of 298 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":125},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW 1 \/ 1 (100%)\r\nNotice: fwrite(): Write of 63 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.010, Memory: 8.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 1, Assertions: 0, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":125},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW 1 \/ 1 (100%)\r\nNotice: fwrite(): Write of 63 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.009, Memory: 8.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 1, Assertions: 0, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":129},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n- if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n+ if ($stmt->execute([$product->getPrice(), $product->getImage()])) {\r\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], $product->getImage() . self::UPLOAD_PATH);\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n- move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n+ move_uploaded_file($files['image']['tmp_name'], $product->getImage() . self::UPLOAD_PATH);\r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n- move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n+ move_uploaded_file($files['image']['tmp_name'], $product->getImage());\r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2301 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH);\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n- move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n+ move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH);\r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2301 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n \n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n- move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n+ \r\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => false, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":131},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n- return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n+ return ['success' => false, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.F\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":131},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\r\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\r\n- return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n+ return ['message' => '\u00a1Producto a\u00f1adido exitosamente!'];\r\n }\r\n } catch (\\Exception $e) {\r\n $this->handleDatabaseError($e);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.E\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n protected function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":139},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\r\n }\r\n }\r\n- public function deleteProduct($id)\r\n+ protected function deleteProduct($id)\r\n {\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW....E\r\nNotice: fwrite(): Write of 511 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\r\nError: Call to protected method Controllers\\AdminController::deleteProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:127\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 6, Assertions: 14, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":143},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen\r\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\r\n- $stmt->execute([$id]);\r\n+ $stmt->execute([]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n \n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":143},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen\r\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\r\n- $stmt->execute([$id]);\r\n+ \r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2316 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.067, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = $image_data['image'] . self::UPLOAD_PATH;\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":147},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$id]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n- $imagePath = self::UPLOAD_PATH . $image_data['image'];\r\n+ $imagePath = $image_data['image'] . self::UPLOAD_PATH;\r\n if (file_exists($imagePath)) {\r\n unlink($imagePath);\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW....F\r\nNotice: fwrite(): Write of 507 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:129\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 15, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":147},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$id]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n- $imagePath = self::UPLOAD_PATH . $image_data['image'];\r\n+ $imagePath = $image_data['image'];\r\n if (file_exists($imagePath)) {\r\n unlink($imagePath);\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH;\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":147},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$id]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n- $imagePath = self::UPLOAD_PATH . $image_data['image'];\r\n+ $imagePath = self::UPLOAD_PATH;\r\n if (file_exists($imagePath)) {\r\n unlink($imagePath);\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":154},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n }\r\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\r\n- if ($stmt->execute([$id])) {\r\n+ if ($stmt->execute([])) {\r\n return ['success' => true, 'message' => 'Producto eliminado'];\r\n }\r\n return ['success' => false, 'message' => 'Error al eliminar el producto'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2308 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => false, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":155},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\r\n if ($stmt->execute([$id])) {\r\n- return ['success' => true, 'message' => 'Producto eliminado'];\r\n+ return ['success' => false, 'message' => 'Producto eliminado'];\r\n }\r\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW....F\r\nNotice: fwrite(): Write of 510 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:129\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 15, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":155},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\r\n if ($stmt->execute([$id])) {\r\n- return ['success' => true, 'message' => 'Producto eliminado'];\r\n+ return ['message' => 'Producto eliminado'];\r\n }\r\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW....E\r\nNotice: fwrite(): Write of 511 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:129\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 6, Assertions: 14, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":172},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n- if (empty($imageName) || !is_string($imageName)) {\r\n+ if (empty($imageName) || is_string($imageName)) {\r\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\r\n }\r\n \/\/ Obtener y validar la extensi\u00f3n","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................F\r\nNotice: fwrite(): Write of 1861 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.066, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\r\nFailed asserting that false is not false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\r\n\r\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":178},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\r\n- if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n+ if (in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n throw new \\Exception('Tipo de archivo no permitido');\r\n }\r\n \/\/ Verificar que el archivo existe en la base de datos","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................F\r\nNotice: fwrite(): Write of 1858 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\r\nFailed asserting that false is not false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\r\n\r\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1."},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":179},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\r\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n- throw new \\Exception('Tipo de archivo no permitido');\r\n+ new \\Exception('Tipo de archivo no permitido');\r\n }\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........................E\r\nNotice: fwrite(): Write of 1960 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension\r\nError: Call to a member function execute() on bool\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:173\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:516\r\n\r\nERRORS!\r\nTests: 25, Assertions: 49, Errors: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if ($stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":185},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n $stmt->execute([$imageName]);\r\n- if (!$stmt->fetch()) {\r\n+ if ($stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n return self::UPLOAD_PATH . $imageName;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................F\r\nNotice: fwrite(): Write of 1858 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\r\nFailed asserting that false is not false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\r\n\r\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":189},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if (!$stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n- return self::UPLOAD_PATH . $imageName;\r\n+ return self::UPLOAD_PATH;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................F\r\nNotice: fwrite(): Write of 1854 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\r\nFailed asserting that '..\/..\/uploaded_img\/' contains \"test.jpg\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:504\r\n\r\nFAILURES!\r\nTests: 24, Assertions: 49, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return true;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":192},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\r\n- return false;\r\n+ return true;\r\n }\r\n }\r\n private function handleImageDelete($imageName)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........................F\r\nNotice: fwrite(): Write of 1960 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:518\r\n\r\nFAILURES!\r\nTests: 25, Assertions: 50, Failures: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":199},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n- if (empty($imageName) || !is_string($imageName)) {\r\n+ if (empty($imageName) || is_string($imageName)) {\r\n return false;\r\n }\r\n \/\/ Verificar en la base de datos","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) && !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":199},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n- if (empty($imageName) || !is_string($imageName)) {\r\n+ if (empty($imageName) && !is_string($imageName)) {\r\n return false;\r\n }\r\n \/\/ Verificar en la base de datos","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW..........................E\r\nNotice: fwrite(): Write of 2147 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName\r\nError: Call to a member function execute() on bool\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:192\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:546\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 28, Assertions: 51, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return true;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":200},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n- return false;\r\n+ return true;\r\n }\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..........................F\r\nNotice: fwrite(): Write of 2123 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:548\r\n\r\nFAILURES!\r\nTests: 27, Assertions: 52, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":205},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n- $stmt->execute([$imageName]);\r\n+ $stmt->execute([]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if (!$result) {\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.059, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n \n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":205},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n- $stmt->execute([$imageName]);\r\n+ \r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if (!$result) {\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":208},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n $stmt->execute([$imageName]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n- if (!$result) {\r\n+ if ($result) {\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2316 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.057, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath($result['image'] . self::UPLOAD_PATH);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":213},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta\r\n- $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n+ $fullPath = realpath($result['image'] . self::UPLOAD_PATH);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.061, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath($result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":213},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta\r\n- $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n+ $fullPath = realpath($result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2308 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.059, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":213},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta\r\n- $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n+ $fullPath = realpath(self::UPLOAD_PATH);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === true || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n- if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n+ if ($fullPath === true || strpos($fullPath, $uploadDir) !== 0) {\r\n return false;\r\n }\r\n \/\/ Eliminar el archivo si existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.060, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Identical","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath !== false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n- if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n+ if ($fullPath !== false || strpos($fullPath, $uploadDir) !== 0) {\r\n return false;\r\n }\r\n \/\/ Eliminar el archivo si existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== -1) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n- if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n+ if ($fullPath === false || strpos($fullPath, $uploadDir) !== -1) {\r\n return false;\r\n }\r\n \/\/ Eliminar el archivo si existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"NotIdentical","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) === 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n- if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n+ if ($fullPath === false || strpos($fullPath, $uploadDir) === 0) {\r\n return false;\r\n }\r\n \/\/ Eliminar el archivo si existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false && strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n- if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n+ if ($fullPath === false && strpos($fullPath, $uploadDir) !== 0) {\r\n return false;\r\n }\r\n \/\/ Eliminar el archivo si existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return true;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":218},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\r\n- return false;\r\n+ return true;\r\n }\r\n \/\/ Eliminar el archivo si existe\r\n if (file_exists($fullPath)) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n protected function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":233},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function updateProduct($postData, $files)\r\n+ protected function updateProduct($postData, $files)\r\n {\r\n try {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW..........E\r\nNotice: fwrite(): Write of 922 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nError: Call to protected method Controllers\\AdminController::updateProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 12, Assertions: 27, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n \n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":236},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $product = new Product();\r\n- $product->setId($postData['update_p_id']);\r\n+ \r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n \n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":237},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $product = new Product();\r\n $product->setId($postData['update_p_id']);\r\n- $product->setName($postData['update_name']);\r\n+ \r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n \n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":238},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($postData['update_p_id']);\r\n $product->setName($postData['update_name']);\r\n- $product->setPrice($postData['update_price']);\r\n+ \r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":240},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setId($postData['update_p_id']);\r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n- if (!empty($files['update_image']['name'])) {\r\n+ if (empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.....................F\r\nNotice: fwrite(): Write of 1736 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithoutImage\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:462\r\n\r\nFAILURES!\r\nTests: 23, Assertions: 44, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] >= 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":241},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n- if ($files['update_image']['size'] > 2000000) {\r\n+ if ($files['update_image']['size'] >= 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] <= 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":241},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n- if ($files['update_image']['size'] > 2000000) {\r\n+ if ($files['update_image']['size'] <= 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW..........F\r\nNotice: fwrite(): Write of 926 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:243\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 28, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":242},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......................F\r\nNotice: fwrite(): Write of 1793 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\r\n\r\nFAILURES!\r\nTests: 23, Assertions: 46, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":242},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......................E\r\nNotice: fwrite(): Write of 1793 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\r\n\r\nERRORS!\r\nTests: 23, Assertions: 45, Errors: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":246},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n- if (!empty($postData['update_old_image'])) {\r\n+ if (empty($postData['update_old_image'])) {\r\n $this->handleImageDelete($postData['update_old_image']);\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n \n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":247},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {\r\n- $this->handleImageDelete($postData['update_old_image']);\r\n+ \r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"UnwrapStrToLower","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = pathinfo($files['update_image']['name'], PATHINFO_EXTENSION);\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":251},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->handleImageDelete($postData['update_old_image']);\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n- $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n+ $extension = pathinfo($files['update_image']['name'], PATHINFO_EXTENSION);\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = '.' . uniqid() . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":252},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = '.' . uniqid() . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":252},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":252},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = uniqid() . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2308 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.058, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . $extension . '.';\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":252},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = uniqid() . $extension . '.';\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.';\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":252},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = uniqid() . '.';\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n \n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":253},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n $newImageName = uniqid() . '.' . $extension;\r\n- $product->setImage($newImageName);\r\n+ \r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":256},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n- \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ \r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.052, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":258},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2304 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":258},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ move_uploaded_file($files['update_image']['tmp_name'], $newImageName);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2305 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":258},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.057, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":262},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n- $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n+ $params = [$product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getId()];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2313 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":265},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\r\n- $params = [$product->getName(), $product->getPrice(), $product->getId()];\r\n+ $params = [$product->getPrice(), $product->getId()];\r\n }\r\n if ($stmt->execute($params)) {\r\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.............................. 31 \/ 31 (100%)\r\nNotice: fwrite(): Write of 2309 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nWARNINGS!\r\nTests: 31, Assertions: 57, Warnings: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => false, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":269},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\r\n }\r\n if ($stmt->execute($params)) {\r\n- return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\r\n+ return ['success' => false, 'message' => 'Producto actualizado exitosamente'];\r\n }\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW..........F\r\nNotice: fwrite(): Write of 925 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\n--\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:243\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 28, Failures: 1, Warnings: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":269},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\r\n }\r\n if ($stmt->execute($params)) {\r\n- return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\r\n+ return ['message' => 'Producto actualizado exitosamente'];\r\n }\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW..........E\r\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:243\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 12, Assertions: 27, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => true, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":272},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($stmt->execute($params)) {\r\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\r\n }\r\n- return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n+ return ['success' => true, 'message' => 'Error al actualizar el producto'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en updateProduct: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............................F\r\nNotice: fwrite(): Write of 2285 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:597\r\n\r\nFAILURES!\r\nTests: 29, Assertions: 55, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":272},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($stmt->execute($params)) {\r\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\r\n }\r\n- return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n+ return ['message' => 'Error al actualizar el producto'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en updateProduct: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............................E\r\nNotice: fwrite(): Write of 2281 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.056, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductDatabaseError\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:597\r\n\r\nERRORS!\r\nTests: 29, Assertions: 54, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n protected function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":279},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n }\r\n }\r\n- public function getAllProducts()\r\n+ protected function getAllProducts()\r\n {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nError: Call to protected method Controllers\\AdminController::getAllProducts() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:212\r\n\r\nERRORS!\r\nTests: 10, Assertions: 23, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":282},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nFailed asserting that actual size 0 matches expected size 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:215\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 25, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n \n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":285},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n- $product->setName($row['name']);\r\n+ \r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nFailed asserting that null matches expected 'Product 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:216\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 26, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":286},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nFailed asserting that null matches expected 99.99.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:217\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 27, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n protected function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":293},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n }\r\n- public function getAllOrders()\r\n+ protected function getAllOrders()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........E\r\nNotice: fwrite(): Write of 961 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nError: Call to protected method Controllers\\AdminController::getAllOrders() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:270\r\n\r\nERRORS!\r\nTests: 12, Assertions: 29, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach (array() as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":297},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 965 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nFailed asserting that actual size 0 matches expected size 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:273\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 31, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n \n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":302},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n- $order->setName($row['name']);\r\n+ \r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 965 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nFailed asserting that null matches expected 'Customer 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:274\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 32, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n \n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":307},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $order->setMethod($row['method']);\r\n $order->setPaymentStatus($row['payment_status']);\r\n $orders[] = $order;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 969 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nFailed asserting that null matches expected 199.98.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:275\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 33, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n protected function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":315},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n }\r\n- public function updateOrderStatus($orderId, $status)\r\n+ protected function updateOrderStatus($orderId, $status)\r\n {\r\n try {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\r\nError: Call to protected method Controllers\\AdminController::updateOrderStatus() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\r\n\r\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n protected function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":329},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function deleteOrder($orderId)\r\n+ protected function deleteOrder($orderId)\r\n {\r\n try {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 548 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder\r\nError: Call to protected method Controllers\\AdminController::deleteOrder() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:141\r\n\r\nERRORS!\r\nTests: 6, Assertions: 16, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n protected function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":342},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function getAllUsers()\r\n+ protected function getAllUsers()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nError: Call to protected method Controllers\\AdminController::getAllUsers() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:108\r\n\r\nERRORS!\r\nTests: 4, Assertions: 8, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach (array() as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":348},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $user = new User();\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 403 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nFailed asserting that actual size 0 matches expected size 2.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:111\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 10, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n \n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":351},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n $user->setId($row['id']);\r\n- $user->setName($row['name']);\r\n+ \r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 407 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nFailed asserting that null matches expected 'Admin User'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:114\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 13, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n \n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":352},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);\r\n- $user->setEmail($row['email']);\r\n+ \r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 404 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nFailed asserting that null matches expected 'user@test.com'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 14, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":363},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function deleteUser($userId)\r\n+ protected function deleteUser($userId)\r\n {\r\n try {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 609 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\r\nError: Call to protected method Controllers\\AdminController::deleteUser() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\r\n\r\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n protected function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":376},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function getAllMessages()\r\n+ protected function getAllMessages()\r\n {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nError: Call to protected method Controllers\\AdminController::getAllMessages() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:176\r\n\r\nERRORS!\r\nTests: 8, Assertions: 18, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach (array() as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":380},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\r\n $messages = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nFailed asserting that actual size 0 matches expected size 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:179\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n \n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":384},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);\r\n- $message->setMessage($row['message']);\r\n+ \r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);\r\n $message->setNumber($row['number']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nFailed asserting that null matches expected 'Test message'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:180\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 21, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n \n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":386},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n- $message->setEmail($row['email']);\r\n+ \r\n $message->setNumber($row['number']);\r\n $messages[] = $message;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nFailed asserting that null matches expected 'test@test.com'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:181\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n private function getTotalPendings()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":397},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function deleteMessage($messageId)\r\n+ protected function deleteMessage($messageId)\r\n {\r\n try {\r\n $query = \"DELETE FROM `message` WHERE id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 759 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage\r\nError: Call to protected method Controllers\\AdminController::deleteMessage() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:192\r\n\r\nERRORS!\r\nTests: 9, Assertions: 22, Errors: 1."},{"mutator":{"mutatorName":"ProtectedVisibility","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n private function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->conn = $conn;\r\n }\r\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\r\n- protected function createUser()\r\n+ private function createUser()\r\n {\r\n return new User();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"NewObject","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n new User();\n return null;\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\r\n protected function createUser()\r\n {\r\n- return new User();\r\n+ new User();\r\n+ return null;\r\n }\r\n protected function createMessage()\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ProtectedVisibility","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n private function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return new User();\r\n }\r\n- protected function createMessage()\r\n+ private function createMessage()\r\n {\r\n return new Message();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\r\nPHPUnit\\Framework\\MockObject\\MethodCannotBeConfiguredException: Trying to configure method \"createMessage\" which cannot be configured because it does not exist, has not been specified, is final, or is static\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:35\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"NewObject","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n new Message();\n return null;\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n protected function createMessage()\r\n {\r\n- return new Message();\r\n+ new Message();\r\n+ return null;\r\n }\r\n public function sendMessage($userData)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message\r\nFailed asserting that null is an instance of class \"Models\\Message\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:179\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 14, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n protected function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return new Message();\r\n }\r\n- public function sendMessage($userData)\r\n+ protected function sendMessage($userData)\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) || isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) && !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) && !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if ((!isset($userData['user_id']) || !isset($userData['name'])) && !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if ((!isset($userData['user_id']) || !isset($userData['name'])) && !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if ((!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email'])) && !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if ((!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email'])) && !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) || !isset($userData['name']) || isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => true, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":32},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n- return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n+ return ['success' => true, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":32},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n- return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n+ return ['message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n \n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();\r\n- $user->setId($userData['user_id']);\r\n+ \r\n if (!$user->exists($this->conn)) {\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if ($user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n- if (!$user->exists($this->conn)) {\r\n+ if ($user->exists($this->conn)) {\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => true, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n if (!$user->exists($this->conn)) {\r\n- return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n+ return ['success' => true, 'message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n if (!$user->exists($this->conn)) {\r\n- return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n+ return ['message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n \n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":43},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();\r\n- $message->setUserId($userData['user_id']);\r\n+ \r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setUserId\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n \n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);\r\n- $message->setName($userData['name']);\r\n+ \r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);\r\n $message->setMessage($userData['message']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setName\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n \n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":45},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);\r\n $message->setName($userData['name']);\r\n- $message->setEmail($userData['email']);\r\n+ \r\n $message->setNumber($userData['number']);\r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 895 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setEmail\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n \n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":46},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setUserId($userData['user_id']);\r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n- $message->setNumber($userData['number']);\r\n+ \r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setNumber\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n \n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":47},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);\r\n- $message->setMessage($userData['message']);\r\n+ \r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 898 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setMessage\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => true, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":50},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n- return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n+ return ['success' => true, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 452 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":50},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n- return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n+ return ['message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 452 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\r\n\r\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => false, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n- return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n+ return ['success' => false, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n- return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n+ return ['message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => true, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n+ return ['success' => true, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 9, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n+ return ['message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\r\n\r\nERRORS!\r\nTests: 5, Assertions: 8, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => true, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 11, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => false, 'message' => $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 629 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\r\nFailed asserting that 'Error de conexi\u00f3n' contains \"Error al enviar mensaje\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:153\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 626 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\r\n\r\nERRORS!\r\nTests: 6, Assertions: 10, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getOrders($userId)\r\n+ protected function getOrders($userId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos\r\nError: Call to protected method Controllers\\OrderController::getOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:206\r\n\r\nERRORS!\r\nTests: 7, Assertions: 24, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":45},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function updatePaymentStatus($orderId, $status)\r\n+ protected function updatePaymentStatus($orderId, $status)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":48},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\r\n- return $stmt->execute([$status, $orderId]);\r\n+ return $stmt->execute([$orderId]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n protected function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":55},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function deleteOrder($orderId)\r\n+ protected function deleteOrder($orderId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\r\n- return $stmt->execute([$orderId]);\r\n+ return $stmt->execute([]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n protected function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":65},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function getAllOrders()\r\n+ protected function getAllOrders()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 477 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nError: Call to protected method Controllers\\OrderController::getAllOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:170\r\n\r\nERRORS!\r\nTests: 5, Assertions: 15, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n \n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":68},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n- $stmt->execute();\r\n+ \r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 473 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach (array() as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 477 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:172\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 16, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setUserId($row['user_id']);\r\n+ \r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 476 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nFailed asserting that null is identical to 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:174\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 18, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":88},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function createOrder($userData, $userId)\r\n+ protected function createOrder($userData, $userId)\r\n {\r\n try {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n \n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":91},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $order = new Order();\r\n- $order->setUserId($userId);\r\n+ \r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n \n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":92},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $order = new Order();\r\n $order->setUserId($userId);\r\n- $order->setName($userData['name']);\r\n+ \r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);\r\n $order->setMethod($userData['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n \n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":93},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setUserId($userId);\r\n $order->setName($userData['name']);\r\n- $order->setNumber($userData['number']);\r\n+ \r\n $order->setEmail($userData['email']);\r\n $order->setMethod($userData['method']);\r\n \/\/ Obtener productos del carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n \n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($userId);\r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n- $order->setEmail($userData['email']);\r\n+ \r\n $order->setMethod($userData['method']);\r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n \n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":95},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);\r\n- $order->setMethod($userData['method']);\r\n+ \r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if (empty($cartItems)) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => true, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":100},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if (empty($cartItems)) {\r\n- return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n+ return ['success' => true, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n \/\/ Calcular total y preparar lista de productos\r\n $cartTotal = 0;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":100},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if (empty($cartItems)) {\r\n- return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n+ return ['message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n \/\/ Calcular total y preparar lista de productos\r\n $cartTotal = 0;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n \n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n- $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n+ \r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() >= 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":140},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() >= 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() <= 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":140},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() <= 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => true, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":141},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n+ return ['success' => true, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..........F\r\nNotice: fwrite(): Write of 987 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.073, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:356\r\n\r\nFAILURES!\r\nTests: 11, Assertions: 41, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":141},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n+ return ['message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..........E\r\nNotice: fwrite(): Write of 983 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.062, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:356\r\n\r\nERRORS!\r\nTests: 11, Assertions: 40, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n \n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":150},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n- $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n+ \r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":163},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n- \/\/ Limpiar carrito\r\n- $this->clearCart($userId);\r\n+ \r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"prepare\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => false, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":165},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n- return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n+ return ['success' => false, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":165},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n- return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n+ return ['message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 166 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":168},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n+ return ['success' => true, 'message' => 'Error al procesar el pedido'];\r\n }\r\n }\r\n private function getCartItems($userId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 1071 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:382\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 45, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":168},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al procesar el pedido'];\r\n+ return ['message' => 'Error al procesar el pedido'];\r\n }\r\n }\r\n private function getCartItems($userId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........E\r\nNotice: fwrite(): Write of 1071 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_al_crear_pedido\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:382\r\n\r\nERRORS!\r\nTests: 12, Assertions: 44, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":174},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function getCartItems($userId)\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n }\r\n private function clearCart($userId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n \n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":174},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function getCartItems($userId)\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n }\r\n private function clearCart($userId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n \n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":180},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function clearCart($userId)\r\n {\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n }\r\n public function getUserOrders($userId)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n protected function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":183},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n }\r\n- public function getUserOrders($userId)\r\n+ protected function getUserOrders($userId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 256 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.058, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nError: Call to protected method Controllers\\OrderController::getUserOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\r\n\r\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":186},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n \n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":186},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach (array() as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":188},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n $orders = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":190},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setUserId($row['user_id']);\r\n+ \r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nFailed asserting that null is identical to 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:104\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n protected function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":209},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function getAllProducts()\r\n+ protected function getAllProducts()\r\n {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Controllers\\OrderController::getAllProducts() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\r\n\r\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":213},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 745 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:249\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 27, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":215},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setName($row['name']);\r\n+ \r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nFailed asserting that null matches expected 'Producto 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:251\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 29, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":227},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function getAllUsers()\r\n+ protected function getAllUsers()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Controllers\\OrderController::getAllUsers() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\r\n\r\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n \n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":230},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n- $stmt->execute();\r\n+ \r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach (array() as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":232},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $user = new User();\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:283\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 32, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n \n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":234},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n- $user->setName($row['name']);\r\n+ \r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 819 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nFailed asserting that null matches expected 'Usuario 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:285\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 34, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getLatestProducts($limit = 6)\r\n+ protected function getLatestProducts($limit = 6)\r\n {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nError: Call to protected method Controllers\\ProductController::getLatestProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n \n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"SELECT * FROM products LIMIT :limit\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n- $stmt->execute();\r\n+ \r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n $stmt->execute();\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nUndefined array key 0\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:50\r\n\r\nERRORS!\r\nTests: 1, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n \n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":28},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n- $product->setName($row['name']);\r\n+ \r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nFailed asserting that null is identical to 'Producto Test'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:51\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n protected function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function addToCart($userId, $productData)\r\n+ protected function addToCart($userId, $productData)\r\n {\r\n try {\r\n $cart = new Cart();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n \n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":43},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $cart = new Cart();\r\n- $cart->setUserId($userId);\r\n+ \r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n \n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $cart = new Cart();\r\n $cart->setUserId($userId);\r\n- $cart->setName($productData['product_name']);\r\n+ \r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);\r\n $cart->setImage($productData['product_image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n \n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":45},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart = new Cart();\r\n $cart->setUserId($userId);\r\n $cart->setName($productData['product_name']);\r\n- $cart->setPrice($productData['product_price']);\r\n+ \r\n $cart->setQuantity($productData['product_quantity']);\r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n \n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":46},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setUserId($userId);\r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n- $cart->setQuantity($productData['product_quantity']);\r\n+ \r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n \n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":47},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);\r\n- $cart->setImage($productData['product_image']);\r\n+ \r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n- $stmt->execute([$userId, $cart->getName()]);\r\n+ $stmt->execute([$cart->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n \n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n- $stmt->execute([$userId, $cart->getName()]);\r\n+ \r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() >= 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":53},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() >= 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() <= 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":53},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() <= 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => true, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n+ return ['success' => true, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n+ return ['message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n \n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n+ \r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nExpectation failed for method name is \"execute\" when invoked 2 time(s).\r\nMethod was expected to be called 2 times, actually called 1 times.\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => false, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n- return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n+ return ['success' => false, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n- return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n+ return ['message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n+ return ['success' => true, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n public function getAllProducts()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1456 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 49, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n+ return ['message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n public function getAllProducts()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............E\r\nNotice: fwrite(): Write of 1460 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\r\n\r\nERRORS!\r\nTests: 15, Assertions: 48, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n protected function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":77},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n- public function getAllProducts()\r\n+ protected function getAllProducts()\r\n {\r\n try {\r\n $query = \"SELECT * FROM products\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nError: Call to protected method Controllers\\ProductController::getAllProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:200\r\n\r\nERRORS!\r\nTests: 7, Assertions: 22, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n \n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":81},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM products\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 28, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":84},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nFailed asserting that actual size 0 matches expected size 2.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:202\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 23, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n \n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":87},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n- $product->setName($row['name']);\r\n+ \r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nFailed asserting that null matches expected 'Producto 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:204\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 25, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n protected function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":99},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function getCartItems($userId)\r\n+ protected function getCartItems($userId)\r\n {\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\r\nError: Call to protected method Controllers\\ProductController::getCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:107\r\n\r\nERRORS!\r\nTests: 3, Assertions: 9, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":103},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\r\nFailed asserting that two arrays are identical.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-Array &0 (\r\n- 0 => Array &1 (\r\n- 'id' => 1\r\n- 'name' => 'Producto Test'\r\n- 'price' => 99.99\r\n- 'quantity' => 1\r\n- 'image' => 'test.jpg'\r\n- )\r\n-)\r\n+Array &0 ()\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:109\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 10, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":103},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 12, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n protected function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":111},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function updateCartQuantity($cartId, $quantity)\r\n+ protected function updateCartQuantity($cartId, $quantity)\r\n {\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":115},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$quantity, $cartId]);\r\n+ $stmt->execute([$cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":115},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$quantity, $cartId]);\r\n+ \r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => false, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":116},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$quantity, $cartId]);\r\n- return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n+ return ['success' => false, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 13, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":116},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$quantity, $cartId]);\r\n- return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n+ return ['message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\r\n\r\nERRORS!\r\nTests: 4, Assertions: 12, Errors: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al actualizar cantidad: \");\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al actualizar cantidad: \");\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \");\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ error_log(\"Error al actualizar cantidad: \");\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":119},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n+ return ['success' => true, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n public function deleteCartItem($cartId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":119},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n+ return ['message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n public function deleteCartItem($cartId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n protected function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n- public function deleteCartItem($cartId)\r\n+ protected function deleteCartItem($cartId)\r\n {\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":127},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cartId]);\r\n+ $stmt->execute([]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":127},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cartId]);\r\n+ \r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":128},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cartId]);\r\n- return true;\r\n+ return false;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 534 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:149\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 17, Failures: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al eliminar item: \");\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al eliminar item: \");\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \");\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ error_log(\"Error al eliminar item: \");\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n \n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ \r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return true;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":131},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n- return false;\r\n+ return true;\r\n }\r\n }\r\n public function deleteAllCartItems($userId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n protected function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":135},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function deleteAllCartItems($userId)\r\n+ protected function deleteAllCartItems($userId)\r\n {\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nError: Call to protected method Controllers\\ProductController::deleteAllCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:166\r\n\r\nERRORS!\r\nTests: 6, Assertions: 19, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":139},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":139},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ \r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 631 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":140},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$userId]);\r\n- return true;\r\n+ return false;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 631 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return true;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":143},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n- return false;\r\n+ return true;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1386 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:317\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 47, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":11},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function searchProducts($searchTerm)\r\n+ protected function searchProducts($searchTerm)\r\n {\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 217 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.102, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados\r\nError: Call to protected method Controllers\\SearchController::searchProducts() from scope Tests\\Unit\\Controllers\\SearchControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:38\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";\r\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\r\n- $stmt->execute([$searchTerm]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nParameter 0 for invocation PDOStatement::execute(Array ()): bool does not match expected value.\r\nFailed asserting that two arrays are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n Array (\r\n- 0 => '%%'\r\n )\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n \n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";\r\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\r\n- $stmt->execute([$searchTerm]);\r\n+ \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en b\u00fasqueda: \");\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en b\u00fasqueda: \");\r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '[11-Dec-2024 17:31:12 Europe\/Berlin] Error de pruebaError en b\u00fasqueda: \\r\\n\r\n' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '[11-Dec-2024 17:31:13 Europe\/Berlin] Error de prueba\\r\\n\r\n' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \");\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ error_log(\"Error en b\u00fasqueda: \");\r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '[11-Dec-2024 17:31:13 Europe\/Berlin] Error en b\u00fasqueda: \\r\\n\r\n' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 651 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, []);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function hashPassword($password)\r\n {\r\n- return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n+ return password_hash($password, PASSWORD_BCRYPT, []);\r\n }\r\n private function verifyPassword($password, $hashedPassword)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 1132 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.532, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\r\nFailed asserting that '$2y$10$XDgAfdc4CNZQgmDaK1V58OdWUiq2Rd4AE28Mj1sYl3KQMMfGnTQ7.' contains \"$2y$12$\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:233\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 23, Failures: 1."},{"mutator":{"mutatorName":"FunctionCall","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n return null;\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function hashPassword($password)\r\n {\r\n- return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n+ password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n+ return null;\r\n }\r\n private function verifyPassword($password, $hashedPassword)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 1132 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:01.332, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:232\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"FunctionCall","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n password_verify($password, $hashedPassword);\n return null;\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function verifyPassword($password, $hashedPassword)\r\n {\r\n- return password_verify($password, $hashedPassword);\r\n+ password_verify($password, $hashedPassword);\r\n+ return null;\r\n }\r\n public function registerUser($userData)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.371, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:62\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n protected function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return password_verify($password, $hashedPassword);\r\n }\r\n- public function registerUser($userData)\r\n+ protected function registerUser($userData)\r\n {\r\n try {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\r\nError: Call to protected method Controllers\\UserController::registerUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:31\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => true, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);\r\n if ($stmt->fetch()) {\r\n- return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n+ return ['success' => true, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 550 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.342, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 10, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);\r\n if ($stmt->fetch()) {\r\n- return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n+ return ['message' => 'El correo ya est\u00e1 registrado'];\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 550 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.373, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:117\r\n\r\nERRORS!\r\nTests: 5, Assertions: 9, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n \n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n- $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n+ \r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................E 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 2984 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:01.448, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\r\nUndefined array key 3\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:649\r\n\r\nERRORS!\r\nTests: 34, Assertions: 62, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n- $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n+ $stmt->execute([$user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................E 34 \/ 34 (100%)\r\nNotice: fwrite(): Write of 3008 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.598, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\r\nUndefined array key 3\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:649\r\n\r\nERRORS!\r\nTests: 34, Assertions: 62, Errors: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => false, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":49},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n- return ['success' => true, 'message' => 'Registro exitoso!'];\r\n+ return ['success' => false, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.244, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:37\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":49},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n- return ['success' => true, 'message' => 'Registro exitoso!'];\r\n+ return ['message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.237, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:37\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":52},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el registro'];\r\n+ return ['success' => true, 'message' => 'Error en el registro'];\r\n }\r\n }\r\n public function loginUser($email, $password)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.354, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:135\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":52},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el registro'];\r\n+ return ['message' => 'Error en el registro'];\r\n }\r\n }\r\n public function loginUser($email, $password)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.361, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:135\r\n\r\nERRORS!\r\nTests: 6, Assertions: 11, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n protected function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":56},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }\r\n- public function loginUser($email, $password)\r\n+ protected function loginUser($email, $password)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.333, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nError: Call to protected method Controllers\\UserController::loginUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:60\r\n\r\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n \n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n- $stmt->execute([$email]);\r\n+ \r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($user && $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 684 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.351, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Error en el inicio de sesi\u00f3n'\r\n+'Correo o contrase\u00f1a incorrectos'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:150\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n- $stmt->execute([$email]);\r\n+ $stmt->execute([]);\r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($user && $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........................F\r\nNotice: fwrite(): Write of 2462 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.476, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_parametros_vacios\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Error en el inicio de sesi\u00f3n'\r\n+'Correo o contrase\u00f1a incorrectos'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:503\r\n\r\nFAILURES!\r\nTests: 28, Assertions: 48, Failures: 1."},{"mutator":{"mutatorName":"LogicalAnd","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user || $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n $stmt->execute([$email]);\r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n- if ($user && $this->verifyPassword($password, $user['password'])) {\r\n+ if ($user || $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.291, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\r\nFailed asserting that two strings are identical.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Correo o contrase\u00f1a incorrectos'\r\n+'Error en el inicio de sesi\u00f3n'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:78\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => false, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":67},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];\r\n $_SESSION['user_email'] = $user['email'];\r\n- return ['success' => true, 'user_type' => $user['user_type']];\r\n+ return ['success' => false, 'user_type' => $user['user_type']];\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:62\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":67},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];\r\n $_SESSION['user_email'] = $user['email'];\r\n- return ['success' => true, 'user_type' => $user['user_type']];\r\n+ return ['user_type' => $user['user_type']];\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.338, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:62\r\n\r\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => true, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_email'] = $user['email'];\r\n return ['success' => true, 'user_type' => $user['user_type']];\r\n }\r\n- return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n+ return ['success' => true, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.338, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:77\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_email'] = $user['email'];\r\n return ['success' => true, 'user_type' => $user['user_type']];\r\n }\r\n- return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n+ return ['message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.349, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:77\r\n\r\nERRORS!\r\nTests: 3, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n+ return ['success' => true, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }\r\n public function logout()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 688 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.386, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:149\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 14, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n+ return ['message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }\r\n public function logout()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 692 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.404, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:149\r\n\r\nERRORS!\r\nTests: 7, Assertions: 13, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n protected function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":99},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\r\n }\r\n }\r\n- public function getUserById($userId)\r\n+ protected function getUserById($userId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 459 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.343, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id\r\nError: Call to protected method Controllers\\UserController::getUserById() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:95\r\n\r\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":102},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener usuario: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............................F\r\nNotice: fwrite(): Write of 2715 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.576, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_id_nulo\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nParameter 0 for invocation PDOStatement::execute(Array ()): bool does not match expected value.\r\nFailed asserting that two arrays are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n Array (\r\n- 0 => null\r\n )\r\n\r\nFAILURES!\r\nTests: 31, Assertions: 54, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":102},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener usuario: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............................F\r\nNotice: fwrite(): Write of 2714 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.540, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::getUserById_falla_con_id_nulo\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 31, Assertions: 54, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n protected function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":111},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n }\r\n \/\/ Alias para mantener compatibilidad\r\n- public function register($userData)\r\n+ protected function register($userData)\r\n {\r\n return $this->registerUser($userData);\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 949 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.584, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register\r\nError: Call to protected method Controllers\\UserController::register() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:195\r\n\r\nERRORS!\r\nTests: 10, Assertions: 18, Errors: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getUserId()\r\n+ protected function getUserId()\r\n {\r\n return $this->userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getUserId() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:63\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->userId;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":16},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getPrice()\r\n+ protected function getPrice()\r\n {\r\n return $this->price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getPrice() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:65\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n protected function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->price;\r\n }\r\n- public function getQuantity()\r\n+ protected function getQuantity()\r\n {\r\n return $this->quantity;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 267 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getQuantity() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:66\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n protected function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->quantity;\r\n }\r\n- public function getImage()\r\n+ protected function getImage()\r\n {\r\n return $this->image;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getImage() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:67\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n protected function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->image;\r\n }\r\n \/\/ Setters\r\n- public function setUserId($userId)\r\n+ protected function setUserId($userId)\r\n {\r\n $this->userId = $userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userId = $userId;\r\n }\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setPrice($price)\r\n+ protected function setPrice($price)\r\n {\r\n $this->price = $price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n protected function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->price = $price;\r\n }\r\n- public function setQuantity($quantity)\r\n+ protected function setQuantity($quantity)\r\n {\r\n $this->quantity = $quantity;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n protected function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->quantity = $quantity;\r\n }\r\n- public function setImage($image)\r\n+ protected function setImage($image)\r\n {\r\n $this->image = $image;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":13},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $number;\r\n private $message;\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\r\nError: Call to protected method Models\\Message::getId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:28\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getUserId()\r\n+ protected function getUserId()\r\n {\r\n return $this->userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\r\nError: Call to protected method Models\\Message::getUserId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:36\r\n\r\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->userId;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\r\nError: Call to protected method Models\\Message::getName() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:44\r\n\r\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":16},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getEmail()\r\n+ protected function getEmail()\r\n {\r\n return $this->email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\r\nError: Call to protected method Models\\Message::getEmail() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:52\r\n\r\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n protected function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->email;\r\n }\r\n- public function getNumber()\r\n+ protected function getNumber()\r\n {\r\n return $this->number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\r\nError: Call to protected method Models\\Message::getNumber() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:60\r\n\r\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n protected function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->number;\r\n }\r\n- public function getMessage()\r\n+ protected function getMessage()\r\n {\r\n return $this->message;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\r\nError: Call to protected method Models\\Message::getMessage() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:68\r\n\r\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n protected function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->message;\r\n }\r\n \/\/ Setters\r\n- public function setUserId($userId)\r\n+ protected function setUserId($userId)\r\n {\r\n $this->userId = $userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\r\nError: Call to protected method Models\\Message::setUserId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:35\r\n\r\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userId = $userId;\r\n }\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\r\nError: Call to protected method Models\\Message::setName() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:43\r\n\r\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setEmail($email)\r\n+ protected function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\r\nError: Call to protected method Models\\Message::setEmail() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:51\r\n\r\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n protected function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->email = $email;\r\n }\r\n- public function setNumber($number)\r\n+ protected function setNumber($number)\r\n {\r\n $this->number = $number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\r\nError: Call to protected method Models\\Message::setNumber() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:59\r\n\r\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n protected function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->number = $number;\r\n }\r\n- public function setMessage($message)\r\n+ protected function setMessage($message)\r\n {\r\n $this->message = $message;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 542 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\r\nError: Call to protected method Models\\Message::setMessage() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:67\r\n\r\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n protected function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->message = $message;\r\n }\r\n- public function exists($conn)\r\n+ protected function exists($conn)\r\n {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 750 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\r\nError: Call to protected method Models\\Message::exists() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:128\r\n\r\nERRORS!\r\nTests: 9, Assertions: 12, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n \n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);\r\n- $stmt->execute([$this->userId, $this->message]);\r\n+ \r\n return $stmt->rowCount() > 0;\r\n }\r\n public function save($conn)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 750 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n protected function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":34},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$this->userId, $this->message]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n- public function save($conn)\r\n+ protected function save($conn)\r\n {\r\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $conn->prepare($sql);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 590 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje\r\nError: Call to protected method Models\\Message::save() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:88\r\n\r\nERRORS!\r\nTests: 7, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n protected function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":46},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $conn->prepare($sql);\r\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\r\nError: Call to protected method Models\\Message::setId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:27\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $placedOn;\r\n private $paymentStatus;\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\r\nError: Call to protected method Models\\Order::getId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:322\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\r\n\r\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getUserId()\r\n+ protected function getUserId()\r\n {\r\n return $this->userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getUserId() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:151\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":20},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->userId;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getName() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:131\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getNumber()\r\n+ protected function getNumber()\r\n {\r\n return $this->number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getNumber() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:132\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n protected function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->number;\r\n }\r\n- public function getEmail()\r\n+ protected function getEmail()\r\n {\r\n return $this->email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getEmail() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:133\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n protected function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->email;\r\n }\r\n- public function getMethod()\r\n+ protected function getMethod()\r\n {\r\n return $this->method;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getMethod() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:134\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n protected function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->method;\r\n }\r\n- public function getAddress()\r\n+ protected function getAddress()\r\n {\r\n return $this->address;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getAddress() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:135\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n protected function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->address;\r\n }\r\n- public function getTotalProducts()\r\n+ protected function getTotalProducts()\r\n {\r\n return $this->totalProducts;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getTotalProducts() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:136\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n protected function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":26},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->totalProducts;\r\n }\r\n- public function getTotalPrice()\r\n+ protected function getTotalPrice()\r\n {\r\n return $this->totalPrice;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getTotalPrice() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:137\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n protected function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":28},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->placedOn;\r\n }\r\n- public function getPaymentStatus()\r\n+ protected function getPaymentStatus()\r\n {\r\n return $this->paymentStatus;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\r\nError: Call to protected method Models\\Order::getPaymentStatus() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:322\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\r\n\r\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n protected function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->paymentStatus;\r\n }\r\n \/\/ Setters\r\n- public function setUserId($userId)\r\n+ protected function setUserId($userId)\r\n {\r\n $this->userId = $userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":32},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userId = $userId;\r\n }\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setNumber($number)\r\n+ protected function setNumber($number)\r\n {\r\n $this->number = $number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n protected function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":34},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->number = $number;\r\n }\r\n- public function setEmail($email)\r\n+ protected function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n protected function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->email = $email;\r\n }\r\n- public function setMethod($method)\r\n+ protected function setMethod($method)\r\n {\r\n $this->method = $method;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n protected function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->method = $method;\r\n }\r\n- public function setAddress($address)\r\n+ protected function setAddress($address)\r\n {\r\n $this->address = $address;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::setAddress() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:120\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n protected function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->address = $address;\r\n }\r\n- public function setTotalProducts($totalProducts)\r\n+ protected function setTotalProducts($totalProducts)\r\n {\r\n $this->totalProducts = $totalProducts;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::setTotalProducts() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:121\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n protected function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->totalProducts = $totalProducts;\r\n }\r\n- public function setTotalPrice($totalPrice)\r\n+ protected function setTotalPrice($totalPrice)\r\n {\r\n $this->totalPrice = $totalPrice;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 166 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::setTotalPrice() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:122\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n protected function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->totalPrice = $totalPrice;\r\n }\r\n- public function setPaymentStatus($status)\r\n+ protected function setPaymentStatus($status)\r\n {\r\n $this->paymentStatus = $status;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nError: Call to protected method Models\\Order::setPaymentStatus() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:198\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\r\n\r\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n protected function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->paymentStatus = $status;\r\n }\r\n- public function setPlacedOn($placedOn)\r\n+ protected function setPlacedOn($placedOn)\r\n {\r\n $this->placedOn = $placedOn;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nError: Call to protected method Models\\Order::setPlacedOn() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:199\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\r\n\r\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n protected function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->placedOn = $placedOn;\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n return $this;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\r\nError: Call to protected method Models\\Order::setId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:42\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:24\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":11},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $price;\r\n private $image;\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW..........E\r\nNotice: fwrite(): Write of 926 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nError: Call to protected method Models\\Product::getId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:262\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 12, Assertions: 27, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":12},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:251\r\n\r\nERRORS!\r\nTests: 8, Assertions: 28, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":13},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getPrice()\r\n+ protected function getPrice()\r\n {\r\n return $this->price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.E\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nError: Call to protected method Models\\Product::getPrice() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:129\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n protected function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->price;\r\n }\r\n- public function getImage()\r\n+ protected function getImage()\r\n {\r\n return $this->image;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nW.E\r\nNotice: fwrite(): Write of 299 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nError: Call to protected method Models\\Product::getImage() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:129\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\r\n\r\n--\r\n\r\nThere was 1 warning:\r\n\r\n1) Warning\r\nNo tests found in class \"Tests\\Mutation\\AdminControllerMutationTest\".\r\n\r\nERRORS!\r\nTests: 3, Assertions: 5, Errors: 1, Warnings: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->image;\r\n }\r\n \/\/ Setters\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::setName() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:215\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\r\n\r\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setPrice($price)\r\n+ protected function setPrice($price)\r\n {\r\n $this->price = $price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::setPrice() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:216\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\r\n\r\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n protected function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->price = $price;\r\n }\r\n- public function setImage($image)\r\n+ protected function setImage($image)\r\n {\r\n $this->image = $image;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::setImage() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:217\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:247\r\n\r\nERRORS!\r\nTests: 8, Assertions: 26, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n protected function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->image = $image;\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 200 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nError: Call to protected method Models\\Product::setId() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:27\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n protected function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":16},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->userType = 'user';\r\n }\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 609 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\r\nError: Call to protected method Models\\User::getId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:369\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\r\n\r\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:285\r\n\r\nERRORS!\r\nTests: 9, Assertions: 33, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getEmail()\r\n+ protected function getEmail()\r\n {\r\n return $this->email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nError: Call to protected method Models\\User::getEmail() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\r\n\r\nERRORS!\r\nTests: 4, Assertions: 13, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n protected function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->email;\r\n }\r\n- public function getUserType()\r\n+ protected function getUserType()\r\n {\r\n return $this->userType;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 192 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type\r\nError: Call to protected method Models\\User::getUserType() from scope Tests\\Unit\\Models\\UserTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:26\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->userType;\r\n }\r\n \/\/ Setters\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::setName() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:234\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\r\n\r\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setEmail($email)\r\n+ protected function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::setEmail() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:235\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\r\n\r\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n protected function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->email = $email;\r\n }\r\n- public function setPassword($password)\r\n+ protected function setPassword($password)\r\n {\r\n $this->password = password_hash($password, PASSWORD_DEFAULT);\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 250 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado\r\nError: Call to protected method Models\\User::setPassword() from scope Tests\\Unit\\Models\\UserTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:33\r\n\r\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n protected function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->password = password_hash($password, PASSWORD_DEFAULT);\r\n }\r\n- public function setUserType($userType)\r\n+ protected function setUserType($userType)\r\n {\r\n $this->userType = $userType;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 823 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::setUserType() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:236\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:281\r\n\r\nERRORS!\r\nTests: 9, Assertions: 31, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n protected function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":28},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userType = $userType;\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n return $this;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"This","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return null;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function setId($id)\r\n {\r\n $this->id = $id;\r\n- return $this;\r\n+ return null;\r\n }\r\n public function exists($conn)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n protected function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->id = $id;\r\n return $this;\r\n }\r\n- public function exists($conn)\r\n+ protected function exists($conn)\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function exists($conn)\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n- $stmt->execute([$this->id]);\r\n+ $stmt->execute([]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n \n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function exists($conn)\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n- $stmt->execute([$this->id]);\r\n+ \r\n return $stmt->rowCount() > 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() >= 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);\r\n- return $stmt->rowCount() > 0;\r\n+ return $stmt->rowCount() >= 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() <= 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);\r\n- return $stmt->rowCount() > 0;\r\n+ return $stmt->rowCount() <= 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"}],"errored":[],"syntaxErrors":[],"uncovered":[],"ignored":[]} \ No newline at end of file +{"stats":{"totalMutantsCount":435,"killedCount":272,"notCoveredCount":0,"escapedCount":152,"errorCount":0,"syntaxErrorCount":0,"skippedCount":0,"ignoredCount":0,"timeOutCount":11,"msi":65.06,"mutationCodeCoverage":100,"coveredCodeMsi":65.06},"escaped":[{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":43},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setId($row['id']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2749 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n \n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":55},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function getTotalCompleted()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n- $stmt->execute();\r\n+ \r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2753 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setId($row['id']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $total += $order->getTotalPrice();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n \n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $product = new Product();\r\n $product->setName($postData['name']);\r\n- $product->setPrice($postData['price']);\r\n+ \r\n $product->setImage($files['image']['name']);\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n \n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setName($postData['name']);\r\n $product->setPrice($postData['price']);\r\n- $product->setImage($files['image']['name']);\r\n+ \r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => true, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":125},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya existe'];\r\n+ return ['success' => true, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n. 1 \/ 1 (100%)\r\nNotice: fwrite(): Write of 101 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.009, Memory: 8.00 MB\r\n\r\nOK (1 test, 1 assertion)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":125},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya existe'];\r\n+ return ['message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n. 1 \/ 1 (100%)\r\nNotice: fwrite(): Write of 101 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.007, Memory: 8.00 MB\r\n\r\nOK (1 test, 1 assertion)"},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] >= 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":128},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n- if ($files['image']['size'] > 2000000) {\r\n+ if ($files['image']['size'] >= 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2810 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":129},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":129},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\r\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":147},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen\r\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\r\n- $stmt->execute([$id]);\r\n+ $stmt->execute([]);\r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2818 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n \n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":147},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen\r\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\r\n- $stmt->execute([$id]);\r\n+ \r\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2813 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n \n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":153},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($image_data) {\r\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\r\n if (file_exists($imagePath)) {\r\n- unlink($imagePath);\r\n+ \r\n }\r\n }\r\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2818 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":190},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n $stmt->execute([$imageName]);\r\n if (!$stmt->fetch()) {\r\n- throw new \\Exception('Archivo no encontrado en la base de datos');\r\n+ new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n return self::UPLOAD_PATH . $imageName;\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2753 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":209},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n- $stmt->execute([$imageName]);\r\n+ $stmt->execute([]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if (!$result) {\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n \n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":209},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\r\n- $stmt->execute([$imageName]);\r\n+ \r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if (!$result) {\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2753 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return true;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":213},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$imageName]);\r\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if (!$result) {\r\n- return false;\r\n+ return true;\r\n }\r\n \/\/ Construir y validar la ruta\r\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath($result['image'] . self::UPLOAD_PATH);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta\r\n- $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n+ $fullPath = realpath($result['image'] . self::UPLOAD_PATH);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath($result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta\r\n- $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n+ $fullPath = realpath($result['image']);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":217},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n \/\/ Construir y validar la ruta\r\n- $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\r\n+ $fullPath = realpath(self::UPLOAD_PATH);\r\n $uploadDir = realpath(self::UPLOAD_PATH);\r\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\r\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n \n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":240},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $product = new Product();\r\n- $product->setId($postData['update_p_id']);\r\n+ \r\n $product->setName($postData['update_name']);\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n \n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":241},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $product = new Product();\r\n $product->setId($postData['update_p_id']);\r\n- $product->setName($postData['update_name']);\r\n+ \r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2813 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n \n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":242},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($postData['update_p_id']);\r\n $product->setName($postData['update_name']);\r\n- $product->setPrice($postData['update_price']);\r\n+ \r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2749 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n \n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":251},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {\r\n- $this->handleImageDelete($postData['update_old_image']);\r\n+ \r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = '.' . uniqid() . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":256},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = '.' . uniqid() . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":256},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2814 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":256},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = uniqid() . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . $extension . '.';\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":256},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = uniqid() . $extension . '.';\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.';\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":256},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n- $newImageName = uniqid() . '.' . $extension;\r\n+ $newImageName = uniqid() . '.';\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n \n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":257},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Generar nombre \u00fanico para la nueva imagen\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n $newImageName = uniqid() . '.' . $extension;\r\n- $product->setImage($newImageName);\r\n+ \r\n \/\/ Subir nueva imagen\r\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.053, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":260},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n- \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ \r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.067, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":262},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2822 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":262},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ move_uploaded_file($files['update_image']['tmp_name'], $newImageName);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2817 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":262},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $newImageName = uniqid() . '.' . $extension;\r\n $product->setImage($newImageName);\r\n \/\/ Subir nueva imagen\r\n- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\r\n+ move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH);\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.074, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":269},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\r\n } else {\r\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\r\n- $params = [$product->getName(), $product->getPrice(), $product->getId()];\r\n+ $params = [$product->getPrice(), $product->getId()];\r\n }\r\n if ($stmt->execute($params)) {\r\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................... 36 \/ 36 (100%)\r\nNotice: fwrite(): Write of 2846 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.074, Memory: 10.00 MB\r\n\r\nOK (36 tests, 77 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":288},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setId($row['id']);\r\n+ \r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n \n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":299},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function getAllOrders()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n- $stmt->execute();\r\n+ \r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":303},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setId($row['id']);\r\n+ \r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n \n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":304},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n- $order->setUserId($row['user_id']);\r\n+ \r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2765 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.057, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n \n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":305},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n- $order->setPlacedOn($row['placed_on']);\r\n+ \r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n \n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":307},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n- $order->setNumber($row['number']);\r\n+ \r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2764 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.051, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n \n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":308},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setPlacedOn($row['placed_on']);\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n- $order->setEmail($row['email']);\r\n+ \r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.055, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n \n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":309},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n- $order->setAddress($row['address']);\r\n+ \r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2749 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n \n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":310},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);\r\n- $order->setTotalProducts($row['total_products']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $order->setMethod($row['method']);\r\n $order->setPaymentStatus($row['payment_status']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n \n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":312},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n- $order->setMethod($row['method']);\r\n+ \r\n $order->setPaymentStatus($row['payment_status']);\r\n $orders[] = $order;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n \n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":322},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $order = new Order();\r\n- $order->setId($orderId);\r\n+ \r\n $order->setPaymentStatus($status);\r\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\r\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2760 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n \n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":349},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n- $stmt->execute();\r\n+ \r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n \n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":354},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();\r\n- $user->setId($row['id']);\r\n+ \r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);\r\n $user->setUserType($row['user_type']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n \n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":386},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $messages = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $message = new Message();\r\n- $message->setId($row['id']);\r\n+ \r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2765 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.058, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n \n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":387},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n- $message->setUserId($row['user_id']);\r\n+ \r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2757 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.054, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log($userData['user_id'] . \"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ error_log($userData['user_id'] . \"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log($userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ error_log($userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n- \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n- error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n+ \r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al enviar mensaje: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al enviar mensaje: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \");\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ error_log(\"Error al enviar mensaje: \");\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":61},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => $e->getMessage() . 'Error al enviar mensaje: '];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => false, 'message' => $e->getMessage() . 'Error al enviar mensaje: '];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1078 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: '];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => false, 'message' => 'Error al enviar mensaje: '];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n............ 12 \/ 12 (100%)\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (12 tests, 19 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n- $this->handleDatabaseError($e);\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n \n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n- $order->setName($row['name']);\r\n+ \r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n \n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":74},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n- $order->setEmail($row['email']);\r\n+ \r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n \n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":75},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n- $order->setMethod($row['method']);\r\n+ \r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n \n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":76},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n- $order->setAddress($row['address']);\r\n+ \r\n $order->setTotalProducts($row['total_products']);\r\n $order->setTotalPrice($row['total_price']);\r\n $orders[] = $order;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1707 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n \n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":77},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n- $order->setTotalProducts($row['total_products']);\r\n+ \r\n $order->setTotalPrice($row['total_price']);\r\n $orders[] = $order;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1707 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n \n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":78},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);\r\n $order->setTotalProducts($row['total_products']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $orders[] = $order;\r\n }\r\n return $orders;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"LessThan","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] <= 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":108},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if (empty($item['name'])) {\r\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n }\r\n- if ($item['price'] < 0) {\r\n+ if ($item['price'] <= 0) {\r\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = -1;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":114},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n }\r\n \/\/ Calcular total y preparar lista de productos\r\n- $cartTotal = 0;\r\n+ $cartTotal = -1;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach (array() as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":116},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Calcular total y preparar lista de productos\r\n $cartTotal = 0;\r\n $products = [];\r\n- foreach ($cartItems as $item) {\r\n+ foreach (array() as $item) {\r\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = ' (' . $item['name'] . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = ' (' . $item['name'] . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1707 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = ' (' . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.048, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . $item['quantity'] . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . $item['quantity'] . ' (' . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . $item['quantity'] . ' (' . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . ' (' . ')';\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . ')' . $item['quantity'];\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . ' (' . ')' . $item['quantity'];\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'];\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":117},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cartTotal = 0;\r\n $products = [];\r\n foreach ($cartItems as $item) {\r\n- $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\r\n+ $products[] = $item['name'] . ' (' . $item['quantity'];\r\n $cartTotal += $item['price'] * $item['quantity'];\r\n }\r\n $totalProducts = implode(', ', $products);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1698 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - ';\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - ';\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ';\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ';\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $totalProducts = implode(', ', $products);\r\n \/\/ Formatear y establecer direcci\u00f3n\r\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n- \/\/ Establecer valores adicionales en el objeto Order\r\n- $order->setAddress($address);\r\n+ \r\n $order->setTotalProducts($totalProducts);\r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n \n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":131},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n- $order->setTotalProducts($totalProducts);\r\n+ \r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n \n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":132},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Establecer valores adicionales en el objeto Order\r\n $order->setAddress($address);\r\n $order->setTotalProducts($totalProducts);\r\n- $order->setTotalPrice($cartTotal);\r\n+ \r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":140},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n- $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n+ $stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1711 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":160},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n- $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n+ $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":190},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function clearCart($userId)\r\n {\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n }\r\n public function getUserOrders($userId)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1715 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n \n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":202},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);\r\n- $order->setNumber($row['number']);\r\n+ \r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);\r\n $order->setAddress($row['address']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener \u00f3rdenes del usuario: \");\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":214},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener \u00f3rdenes del usuario: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1703 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.047, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":214},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \");\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":214},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener \u00f3rdenes del usuario: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1711 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":214},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":232},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- $this->handleDatabaseError($e);\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................... 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (20 tests, 85 assertions)"},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 5)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getLatestProducts($limit = 6)\r\n+ public function getLatestProducts($limit = 5)\r\n {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"IncrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 7)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getLatestProducts($limit = 6)\r\n+ public function getLatestProducts($limit = 7)\r\n {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n \n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n+ \r\n $stmt->execute();\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setId($row['id']);\r\n+ \r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":29},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n \n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n- $product->setImage($row['image']);\r\n+ \r\n $products[] = $product;\r\n }\r\n return $products;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener productos: \");\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \");\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener productos: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n+ $stmt->execute([$cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al a\u00f1adir al carrito: \");\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al a\u00f1adir al carrito: \");\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1438 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \");\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ error_log(\"Error al a\u00f1adir al carrito: \");\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1466 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n \n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":86},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n- $product->setId($row['id']);\r\n+ \r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":88},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n \n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":89},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);\r\n- $product->setImage($row['image']);\r\n+ \r\n $products[] = $product;\r\n }\r\n return $products;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener todos los productos: \");\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener todos los productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \");\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener todos los productos: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1442 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener items del carrito: \");\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener items del carrito: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \");\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener items del carrito: \");\r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1449 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al eliminar todos los items: \");\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al eliminar todos los items: \");\r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1445 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \");\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ error_log(\"Error al eliminar todos los items: \");\r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1446 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n \n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":142},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n+ \r\n return false;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................ 16 \/ 16 (100%)\r\nNotice: fwrite(): Write of 1450 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nOK (16 tests, 55 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n \n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $user = new User();\r\n- $user->setName($userData['name']);\r\n+ \r\n $user->setEmail($userData['email']);\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.386, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n \n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":26},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n- $user->setEmail($userData['email']);\r\n+ \r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2836 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.399, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"Coalesce","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType('user' ?? $userData['user_type']);\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n $user->setEmail($userData['email']);\r\n- $user->setUserType($userData['user_type'] ?? 'user');\r\n+ $user->setUserType('user' ?? $userData['user_type']);\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.441, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n \n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setName($userData['name']);\r\n $user->setEmail($userData['email']);\r\n- $user->setUserType($userData['user_type'] ?? 'user');\r\n+ \r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.396, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n- $stmt->execute([$user->getEmail()]);\r\n+ $stmt->execute([]);\r\n if ($stmt->fetch()) {\r\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.390, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n \n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user->setUserType($userData['user_type'] ?? 'user');\r\n \/\/ Verificar si el correo ya existe\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n- $stmt->execute([$user->getEmail()]);\r\n+ \r\n if ($stmt->fetch()) {\r\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.783, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en registro: \");\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en registro: \");\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.404, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2832 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.383, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \");\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ error_log(\"Error en registro: \");\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.379, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en registro: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2832 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.386, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en login: \");\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en login: \");\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.359, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2838 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.349, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \");\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ error_log(\"Error en login: \");\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.404, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en login: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.361, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":102},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener usuario: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2838 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.390, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n \n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":102},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener usuario: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.338, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al obtener usuario: \");\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al obtener usuario: \");\r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2836 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.376, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2833 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.391, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n \n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ \r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.461, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \");\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":105},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$userId]);\r\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al obtener usuario: \" . $e->getMessage());\r\n+ error_log(\"Error al obtener usuario: \");\r\n return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................. 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2834 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.535, Memory: 8.00 MB\r\n\r\nOK (33 tests, 61 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);\r\n- $stmt->execute([$this->userId, $this->message]);\r\n+ $stmt->execute([$this->message]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n public function save($conn)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......... 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 672 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $conn->prepare($sql);\r\n- return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\r\n+ return $stmt->execute([$this->name, $this->email, $this->number, $this->message]);\r\n }\r\n public function setId($id)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......... 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 668 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nOK (9 tests, 15 assertions)"},{"mutator":{"mutatorName":"This","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return null;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function setId($id)\r\n {\r\n $this->id = $id;\r\n- return $this;\r\n+ return null;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................... 35 \/ 35 (100%)\r\nNotice: fwrite(): Write of 2761 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nOK (35 tests, 76 assertions)"}],"timeouted":[{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":13},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $user;\r\n private $password;\r\n private $database;\r\n- public function __construct(bool $useEnv = true)\r\n+ public function __construct(bool $useEnv = false)\r\n {\r\n if (!$useEnv) {\r\n $this->setDefaultCredentials();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ? '123456' : getenv('DB_PASSWORD');\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n- $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n+ $this->password = getenv('DB_PASSWORD') ? '123456' : getenv('DB_PASSWORD');\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n }\r\n public function setCredentials(string $host, string $user, string $password, string $database) : void","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ? 'tienda_bd' : getenv('DB_NAME');\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n- $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n+ $this->database = getenv('DB_NAME') ? 'tienda_bd' : getenv('DB_NAME');\r\n }\r\n public function setCredentials(string $host, string $user, string $password, string $database) : void\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array());\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":57},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function connect()\r\n {\r\n try {\r\n- $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\r\n+ $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array());\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log($e->getMessage() . \"Error de conexi\u00f3n: \");\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error de conexi\u00f3n: \");\r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log($e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \");\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ error_log(\"Error de conexi\u00f3n: \");\r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n \n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n- error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n+ \r\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"Concat","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException($e->getMessage() . \"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":64},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ throw new DatabaseException($e->getMessage() . \"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException($e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":64},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ throw new DatabaseException($e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":64},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \", $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....S"}],"killed":[{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $database;\r\n public function __construct(bool $useEnv = true)\r\n {\r\n- if (!$useEnv) {\r\n+ if ($useEnv) {\r\n $this->setDefaultCredentials();\r\n return;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 192 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.014, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\r\nfopen(C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\.env): Failed to open stream: Permission denied\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php:113\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php:20\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:14\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function __construct(bool $useEnv = true)\r\n {\r\n if (!$useEnv) {\r\n- $this->setDefaultCredentials();\r\n+ \r\n return;\r\n }\r\n $envPath = __DIR__ . '\/..\/..\/.env';","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.709, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\r\nFailed asserting that null matches expected 'test_host'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1."},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ? 'db' : getenv('DB_HOST');\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function setDefaultCredentials() : void\r\n {\r\n- $this->host = getenv('DB_HOST') ?: 'db';\r\n+ $this->host = getenv('DB_HOST') ? 'db' : getenv('DB_HOST');\r\n $this->user = getenv('DB_USER') ?: 'root';\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.706, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_env_cuando_existe\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'test_host'\r\n+'db'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:36\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 2, Failures: 1."},{"mutator":{"mutatorName":"Ternary","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ? 'root' : getenv('DB_USER');\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function setDefaultCredentials() : void\r\n {\r\n $this->host = getenv('DB_HOST') ?: 'db';\r\n- $this->user = getenv('DB_USER') ?: 'root';\r\n+ $this->user = getenv('DB_USER') ? 'root' : getenv('DB_USER');\r\n $this->password = getenv('DB_PASSWORD') ?: '123456';\r\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 398 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.704, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_constructor_usa_valores_por_defecto_cuando_no_hay_env\r\nFailed asserting that false matches expected 'root'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:58\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n protected function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->password = $password;\r\n $this->database = $database;\r\n }\r\n- public function connect()\r\n+ protected function connect()\r\n {\r\n try {\r\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\r\nFailed asserting that exception of type \"Error\" matches expected exception \"Exceptions\\DatabaseException\". Message was: \"Call to protected method Config\\Database::connect() from scope Tests\\Unit\\Config\\DatabaseTest\" at\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Config\\DatabaseTest.php:18\r\n.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","mutatedSourceCode":"setDefaultCredentials();\n return;\n }\n $envPath = __DIR__ . '\/..\/..\/.env';\n if (file_exists($envPath)) {\n $env = parse_ini_file($envPath);\n if ($env !== false) {\n $this->host = $env['DB_HOST'];\n $this->user = $env['DB_USER'];\n $this->password = $env['DB_PASSWORD'];\n $this->database = $env['DB_NAME'];\n return;\n }\n }\n $this->setDefaultCredentials();\n }\n private function setDefaultCredentials() : void\n {\n $this->host = getenv('DB_HOST') ?: 'db';\n $this->user = getenv('DB_USER') ?: 'root';\n $this->password = getenv('DB_PASSWORD') ?: '123456';\n $this->database = getenv('DB_NAME') ?: 'tienda_bd';\n }\n public function setCredentials(string $host, string $user, string $password, string $database) : void\n {\n $this->host = $host;\n $this->user = $user;\n $this->password = $password;\n $this->database = $database;\n }\n public function connect()\n {\n try {\n $conn = new \\PDO(\"mysql:host={$this->host};dbname={$this->database}\", $this->user, $this->password, array(\\PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n $conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n return $conn;\n } catch (\\PDOException $e) {\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\n new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Config\\Database.php","originalStartLine":63},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $conn;\r\n } catch (\\PDOException $e) {\r\n error_log(\"Error de conexi\u00f3n: \" . $e->getMessage());\r\n- throw new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n+ new DatabaseException(\"Error de conexi\u00f3n a la base de datos: \" . $e->getMessage(), $e->getCode(), $e);\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.714, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Config\\DatabaseTest::test_conexion_fallida_lanza_excepcion\r\nFailed asserting that exception of type \"Exceptions\\DatabaseException\" is thrown.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":20},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getDashboardData()\r\n+ protected function getDashboardData()\r\n {\r\n $data = [];\r\n \/\/ Obtener total pendientes","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\r\nError: Call to protected method Controllers\\AdminController::getDashboardData() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n protected function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $data['messages_count'] = $this->getMessagesCount();\r\n return $data;\r\n }\r\n- public function getTotalPendings()\r\n+ protected function getTotalPendings()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................E\r\nNotice: fwrite(): Write of 2731 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::obtener_total_pendientes_exitoso\r\nError: Call to protected method Controllers\\AdminController::getTotalPendings() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:721\r\n\r\nERRORS!\r\nTests: 34, Assertions: 69, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n \n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n- $stmt->execute();\r\n+ \r\n $total = 0;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.................................F\r\nNotice: fwrite(): Write of 2735 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::obtener_total_pendientes_exitoso\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 34, Assertions: 72, Failures: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = -1;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n $stmt->execute();\r\n- $total = 0;\r\n+ $total = -1;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 249.0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach (array() as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":41},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\r\n $stmt->execute();\r\n $total = 0;\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1116 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n \n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n- $order->setTotalPrice($row['total_price']);\r\n+ \r\n $total += $order->getTotalPrice();\r\n }\r\n return $total;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1112 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalPendings\r\nFailed asserting that 0 matches expected 250.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:316\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = -1;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":56},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n $stmt->execute();\r\n- $total = 0;\r\n+ $total = -1;\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1194 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that 499.0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach (array() as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":57},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\r\n $stmt->execute();\r\n $total = 0;\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setTotalPrice($row['total_price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1190 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetTotalCompleted\r\nFailed asserting that 0 matches expected 500.0.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:343\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 37, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n protected function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":113},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n error_log(\"Error en la base de datos: \" . $e->getMessage());\r\n throw new \\Exception(\"Error al procesar la solicitud\");\r\n }\r\n- public function addProduct($postData, $files)\r\n+ protected function addProduct($postData, $files)\r\n {\r\n try {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 335 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nError: Call to protected method Controllers\\AdminController::addProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\r\n\r\nERRORS!\r\nTests: 3, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() >= 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":124},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() >= 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() <= 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":124},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya existe\r\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\r\n $stmt->execute([$product->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() <= 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n if ($files['image']['size'] > 2000000) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] <= 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":128},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya existe'];\r\n }\r\n- if ($files['image']['size'] > 2000000) {\r\n+ if ($files['image']['size'] <= 2000000) {\r\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:68\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n protected function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":143},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\r\n }\r\n }\r\n- public function deleteProduct($id)\r\n+ protected function deleteProduct($id)\r\n {\r\n try {\r\n \/\/ Obtener informaci\u00f3n de la imagen","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 544 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteProduct\r\nError: Call to protected method Controllers\\AdminController::deleteProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:127\r\n\r\nERRORS!\r\nTests: 6, Assertions: 15, Errors: 1."},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":177},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n- throw new \\Exception('Nombre de archivo inv\u00e1lido');\r\n+ new \\Exception('Nombre de archivo inv\u00e1lido');\r\n }\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............................E\r\nNotice: fwrite(): Write of 2487 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathWithEmptyAndNonStringName\r\nTypeError: pathinfo(): Argument #1 ($path) must be of type string, array given\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:171\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:638\r\n\r\nERRORS!\r\nTests: 31, Assertions: 60, Errors: 1."},{"mutator":{"mutatorName":"Throw_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":183},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Obtener y validar la extensi\u00f3n\r\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\r\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\r\n- throw new \\Exception('Tipo de archivo no permitido');\r\n+ new \\Exception('Tipo de archivo no permitido');\r\n }\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........................E\r\nNotice: fwrite(): Write of 1956 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePathInvalidExtension\r\nError: Call to a member function execute() on bool\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:177\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:516\r\n\r\nERRORS!\r\nTests: 25, Assertions: 49, Errors: 1."},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if ($stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":189},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar que el archivo existe en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\r\n $stmt->execute([$imageName]);\r\n- if (!$stmt->fetch()) {\r\n+ if ($stmt->fetch()) {\r\n throw new \\Exception('Archivo no encontrado en la base de datos');\r\n }\r\n return self::UPLOAD_PATH . $imageName;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................F\r\nNotice: fwrite(): Write of 1854 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetSecureImagePath\r\nFailed asserting that false is not false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:503\r\n\r\nFAILURES!\r\nTests: 24, Assertions: 48, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return true;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":204},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar el nombre del archivo\r\n if (empty($imageName) || !is_string($imageName)) {\r\n- return false;\r\n+ return true;\r\n }\r\n \/\/ Verificar en la base de datos\r\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........................F\r\nNotice: fwrite(): Write of 2172 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testHandleImageDeleteInvalidName\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:548\r\n\r\nFAILURES!\r\nTests: 28, Assertions: 53, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n protected function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":237},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function updateProduct($postData, $files)\r\n+ protected function updateProduct($postData, $files)\r\n {\r\n try {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........E\r\nNotice: fwrite(): Write of 959 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nError: Call to protected method Controllers\\AdminController::updateProduct() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\r\n\r\nERRORS!\r\nTests: 12, Assertions: 28, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":246},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['success' => true, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................F\r\nNotice: fwrite(): Write of 1850 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\r\n\r\nFAILURES!\r\nTests: 24, Assertions: 47, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":246},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product->setPrice($postData['update_price']);\r\n if (!empty($files['update_image']['name'])) {\r\n if ($files['update_image']['size'] > 2000000) {\r\n- return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n+ return ['message' => 'El tama\u00f1o de la imagen es demasiado grande'];\r\n }\r\n \/\/ Eliminar imagen anterior de forma segura\r\n if (!empty($postData['update_old_image'])) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......................E\r\nNotice: fwrite(): Write of 1853 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProductWithLargeImage\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:484\r\n\r\nERRORS!\r\nTests: 24, Assertions: 46, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n protected function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":283},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\r\n }\r\n }\r\n- public function getAllProducts()\r\n+ protected function getAllProducts()\r\n {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 826 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nError: Call to protected method Controllers\\AdminController::getAllProducts() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:212\r\n\r\nERRORS!\r\nTests: 10, Assertions: 23, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":286},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 830 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nFailed asserting that actual size 0 matches expected size 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:215\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 25, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n \n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":290},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);\r\n- $product->setPrice($row['price']);\r\n+ \r\n $product->setImage($row['image']);\r\n $products[] = $product;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 829 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllProducts\r\nFailed asserting that null matches expected 99.99.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:217\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 27, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n protected function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":297},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $products;\r\n }\r\n- public function getAllOrders()\r\n+ protected function getAllOrders()\r\n {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........E\r\nNotice: fwrite(): Write of 957 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nError: Call to protected method Controllers\\AdminController::getAllOrders() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:270\r\n\r\nERRORS!\r\nTests: 12, Assertions: 29, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach (array() as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":301},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 965 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nFailed asserting that actual size 0 matches expected size 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:273\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 31, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n \n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":306},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setId($row['id']);\r\n $order->setUserId($row['user_id']);\r\n $order->setPlacedOn($row['placed_on']);\r\n- $order->setName($row['name']);\r\n+ \r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);\r\n $order->setAddress($row['address']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 961 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllOrders\r\nFailed asserting that null matches expected 'Customer 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:274\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 32, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n protected function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":319},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n return $orders;\r\n }\r\n- public function updateOrderStatus($orderId, $status)\r\n+ protected function updateOrderStatus($orderId, $status)\r\n {\r\n try {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\r\nError: Call to protected method Controllers\\AdminController::updateOrderStatus() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\r\n\r\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n protected function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":333},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function deleteOrder($orderId)\r\n+ protected function deleteOrder($orderId)\r\n {\r\n try {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 548 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteOrder\r\nError: Call to protected method Controllers\\AdminController::deleteOrder() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:141\r\n\r\nERRORS!\r\nTests: 6, Assertions: 16, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n protected function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":346},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function getAllUsers()\r\n+ protected function getAllUsers()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nError: Call to protected method Controllers\\AdminController::getAllUsers() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:108\r\n\r\nERRORS!\r\nTests: 4, Assertions: 8, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach (array() as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":352},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $user = new User();\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nFailed asserting that actual size 0 matches expected size 2.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:111\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 10, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n \n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":356},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = new User();\r\n $user->setId($row['id']);\r\n $user->setName($row['name']);\r\n- $user->setEmail($row['email']);\r\n+ \r\n $user->setUserType($row['user_type']);\r\n $users[] = $user;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 408 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nFailed asserting that null matches expected 'user@test.com'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 14, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":367},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function deleteUser($userId)\r\n+ protected function deleteUser($userId)\r\n {\r\n try {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 613 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\r\nError: Call to protected method Controllers\\AdminController::deleteUser() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\r\n\r\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n protected function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":380},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function getAllMessages()\r\n+ protected function getAllMessages()\r\n {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.045, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nError: Call to protected method Controllers\\AdminController::getAllMessages() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:176\r\n\r\nERRORS!\r\nTests: 8, Assertions: 18, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach (array() as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":384},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\r\n $messages = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 686 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nFailed asserting that actual size 0 matches expected size 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:179\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n \n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":388},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message = new Message();\r\n $message->setId($row['id']);\r\n $message->setUserId($row['user_id']);\r\n- $message->setMessage($row['message']);\r\n+ \r\n $message->setName($row['name']);\r\n $message->setEmail($row['email']);\r\n $message->setNumber($row['number']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nFailed asserting that null matches expected 'Test message'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:180\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 21, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n \n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":390},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setUserId($row['user_id']);\r\n $message->setMessage($row['message']);\r\n $message->setName($row['name']);\r\n- $message->setEmail($row['email']);\r\n+ \r\n $message->setNumber($row['number']);\r\n $messages[] = $message;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 683 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllMessages\r\nFailed asserting that null matches expected 'test@test.com'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:181\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getDashboardData()\n {\n $data = [];\n \/\/ Obtener total pendientes\n $data['total_pendings'] = $this->getTotalPendings();\n $data['total_completed'] = $this->getTotalCompleted();\n $data['orders_count'] = $this->getOrdersCount();\n $data['products_count'] = $this->getProductsCount();\n $data['users_count'] = $this->getUsersCount();\n $data['admins_count'] = $this->getAdminsCount();\n $data['total_accounts'] = $this->getTotalAccounts();\n $data['messages_count'] = $this->getMessagesCount();\n return $data;\n }\n public function getTotalPendings()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'pendiente'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n }\n }\n private function getTotalCompleted()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders` WHERE payment_status = 'completado'\");\n $stmt->execute();\n $total = 0;\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setTotalPrice($row['total_price']);\n $total += $order->getTotalPrice();\n }\n return $total;\n }\n private function getOrdersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `orders`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getProductsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `products`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getUsersCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getAdminsCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getTotalAccounts()\n {\n $query = \"SELECT COUNT(*) as count FROM `users`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function getMessagesCount()\n {\n $query = \"SELECT COUNT(*) as count FROM `message`\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n return $stmt->fetch(\\PDO::FETCH_ASSOC)['count'];\n }\n private function handleDatabaseError($e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n throw new \\Exception(\"Error al procesar la solicitud\");\n }\n public function addProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setName($postData['name']);\n $product->setPrice($postData['price']);\n $product->setImage($files['image']['name']);\n \/\/ Verificar si el producto ya existe\n $stmt = $this->conn->prepare(\"SELECT name FROM `products` WHERE name = ?\");\n $stmt->execute([$product->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya existe'];\n }\n if ($files['image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n $stmt = $this->conn->prepare(\"INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)\");\n if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) {\n move_uploaded_file($files['image']['tmp_name'], self::UPLOAD_PATH . $product->getImage());\n return ['success' => true, 'message' => '\u00a1Producto a\u00f1adido exitosamente!'];\n }\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return ['success' => false, 'message' => 'Error al a\u00f1adir el producto'];\n }\n }\n public function deleteProduct($id)\n {\n try {\n \/\/ Obtener informaci\u00f3n de la imagen\n $stmt = $this->conn->prepare(\"SELECT image FROM `products` WHERE id = ?\");\n $stmt->execute([$id]);\n $image_data = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($image_data) {\n $imagePath = self::UPLOAD_PATH . $image_data['image'];\n if (file_exists($imagePath)) {\n unlink($imagePath);\n }\n }\n $stmt = $this->conn->prepare(\"DELETE FROM `products` WHERE id = ?\");\n if ($stmt->execute([$id])) {\n return ['success' => true, 'message' => 'Producto eliminado'];\n }\n return ['success' => false, 'message' => 'Error al eliminar el producto'];\n } catch (\\Exception $e) {\n return ['success' => false, 'message' => 'Error al eliminar el producto: ' . $e->getMessage()];\n }\n }\n private function validateImageName($imageName)\n {\n \/\/ Solo permitir letras, n\u00fameros, guiones y puntos\n return preg_match('\/^[a-zA-Z0-9_.-]+$\/', $imageName);\n }\n private function getSecureImagePath($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n throw new \\Exception('Nombre de archivo inv\u00e1lido');\n }\n \/\/ Obtener y validar la extensi\u00f3n\n $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION));\n if (!in_array($extension, self::ALLOWED_EXTENSIONS)) {\n throw new \\Exception('Tipo de archivo no permitido');\n }\n \/\/ Verificar que el archivo existe en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ?\");\n $stmt->execute([$imageName]);\n if (!$stmt->fetch()) {\n throw new \\Exception('Archivo no encontrado en la base de datos');\n }\n return self::UPLOAD_PATH . $imageName;\n } catch (\\Exception $e) {\n error_log(\"Error en getSecureImagePath: \" . $e->getMessage());\n return false;\n }\n }\n private function handleImageDelete($imageName)\n {\n try {\n \/\/ Validar el nombre del archivo\n if (empty($imageName) || !is_string($imageName)) {\n return false;\n }\n \/\/ Verificar en la base de datos\n $stmt = $this->conn->prepare(\"SELECT image FROM products WHERE image = ? LIMIT 1\");\n $stmt->execute([$imageName]);\n $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if (!$result) {\n return false;\n }\n \/\/ Construir y validar la ruta\n $fullPath = realpath(self::UPLOAD_PATH . $result['image']);\n $uploadDir = realpath(self::UPLOAD_PATH);\n \/\/ Verificar que el archivo est\u00e1 dentro del directorio permitido\n if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) {\n return false;\n }\n \/\/ Eliminar el archivo si existe\n if (file_exists($fullPath)) {\n return unlink($fullPath);\n }\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar imagen: \" . $e->getMessage());\n return false;\n }\n }\n public function updateProduct($postData, $files)\n {\n try {\n $product = new Product();\n $product->setId($postData['update_p_id']);\n $product->setName($postData['update_name']);\n $product->setPrice($postData['update_price']);\n if (!empty($files['update_image']['name'])) {\n if ($files['update_image']['size'] > 2000000) {\n return ['success' => false, 'message' => 'El tama\u00f1o de la imagen es demasiado grande'];\n }\n \/\/ Eliminar imagen anterior de forma segura\n if (!empty($postData['update_old_image'])) {\n $this->handleImageDelete($postData['update_old_image']);\n }\n \/\/ Generar nombre \u00fanico para la nueva imagen\n $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION));\n $newImageName = uniqid() . '.' . $extension;\n $product->setImage($newImageName);\n \/\/ Subir nueva imagen\n move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName);\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()];\n } else {\n $stmt = $this->conn->prepare(\"UPDATE `products` SET name = ?, price = ? WHERE id = ?\");\n $params = [$product->getName(), $product->getPrice(), $product->getId()];\n }\n if ($stmt->execute($params)) {\n return ['success' => true, 'message' => 'Producto actualizado exitosamente'];\n }\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n } catch (\\Exception $e) {\n error_log(\"Error en updateProduct: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar el producto'];\n }\n }\n public function getAllProducts()\n {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n }\n public function getAllOrders()\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setPlacedOn($row['placed_on']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setMethod($row['method']);\n $order->setPaymentStatus($row['payment_status']);\n $orders[] = $order;\n }\n return $orders;\n }\n public function updateOrderStatus($orderId, $status)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $order->setPaymentStatus($status);\n $stmt = $this->conn->prepare(\"UPDATE `orders` SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$order->getPaymentStatus(), $order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $order = new Order();\n $order->setId($orderId);\n $stmt = $this->conn->prepare(\"DELETE FROM `orders` WHERE id = ?\");\n return $stmt->execute([$order->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setId($row['id']);\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function deleteUser($userId)\n {\n try {\n $user = new User();\n $user->setId($userId);\n $stmt = $this->conn->prepare(\"DELETE FROM `users` WHERE id = ?\");\n return $stmt->execute([$user->getId()]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n public function getAllMessages()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `message`\");\n $messages = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $message = new Message();\n $message->setId($row['id']);\n $message->setUserId($row['user_id']);\n $message->setMessage($row['message']);\n $message->setName($row['name']);\n $message->setEmail($row['email']);\n $message->setNumber($row['number']);\n $messages[] = $message;\n }\n return $messages;\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function deleteMessage($messageId)\n {\n try {\n $query = \"DELETE FROM `message` WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n return $stmt->execute([$messageId]);\n } catch (\\PDOException $e) {\n $this->handleDatabaseError($e);\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php","originalStartLine":401},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function deleteMessage($messageId)\r\n+ protected function deleteMessage($messageId)\r\n {\r\n try {\r\n $query = \"DELETE FROM `message` WHERE id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 754 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteMessage\r\nError: Call to protected method Controllers\\AdminController::deleteMessage() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:192\r\n\r\nERRORS!\r\nTests: 9, Assertions: 22, Errors: 1."},{"mutator":{"mutatorName":"ProtectedVisibility","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n private function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->conn = $conn;\r\n }\r\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\r\n- protected function createUser()\r\n+ private function createUser()\r\n {\r\n return new User();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"NewObject","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n new User();\n return null;\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\r\n protected function createUser()\r\n {\r\n- return new User();\r\n+ new User();\r\n+ return null;\r\n }\r\n protected function createMessage()\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ProtectedVisibility","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n private function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return new User();\r\n }\r\n- protected function createMessage()\r\n+ private function createMessage()\r\n {\r\n return new Message();\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\r\nPHPUnit\\Framework\\MockObject\\MethodCannotBeConfiguredException: Trying to configure method \"createMessage\" which cannot be configured because it does not exist, has not been specified, is final, or is static\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:35\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"NewObject","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n new Message();\n return null;\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n protected function createMessage()\r\n {\r\n- return new Message();\r\n+ new Message();\r\n+ return null;\r\n }\r\n public function sendMessage($userData)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......F\r\nNotice: fwrite(): Write of 826 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::crear_mensaje_retorna_instancia_message\r\nFailed asserting that null is an instance of class \"Models\\Message\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:179\r\n\r\nFAILURES!\r\nTests: 8, Assertions: 14, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n protected function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return new Message();\r\n }\r\n- public function sendMessage($userData)\r\n+ protected function sendMessage($userData)\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) || isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) && !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) && !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if ((!isset($userData['user_id']) || !isset($userData['name'])) && !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if ((!isset($userData['user_id']) || !isset($userData['name'])) && !isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalOr","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if ((!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email'])) && !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if ((!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email'])) && !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) || !isset($userData['name']) || isset($userData['email']) || !isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n- if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n+ if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || isset($userData['message'])) {\r\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => true, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":32},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n- return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n+ return ['success' => true, 'message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":32},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n \/\/ Validar que todos los campos requeridos existan\r\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\r\n- return ['success' => false, 'message' => 'Faltan campos requeridos'];\r\n+ return ['message' => 'Faltan campos requeridos'];\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n \n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();\r\n- $user->setId($userData['user_id']);\r\n+ \r\n if (!$user->exists($this->conn)) {\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"LogicalNot","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if ($user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Modificar la creaci\u00f3n de User y Message\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n- if (!$user->exists($this->conn)) {\r\n+ if ($user->exists($this->conn)) {\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => true, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n if (!$user->exists($this->conn)) {\r\n- return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n+ return ['success' => true, 'message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $user = $this->createUser();\r\n $user->setId($userData['user_id']);\r\n if (!$user->exists($this->conn)) {\r\n- return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n+ return ['message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n \n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":43},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Usuario no encontrado'];\r\n }\r\n $message = $this->createMessage();\r\n- $message->setUserId($userData['user_id']);\r\n+ \r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.046, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setUserId\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n \n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);\r\n- $message->setName($userData['name']);\r\n+ \r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);\r\n $message->setMessage($userData['message']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setName\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n \n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":45},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message = $this->createMessage();\r\n $message->setUserId($userData['user_id']);\r\n $message->setName($userData['name']);\r\n- $message->setEmail($userData['email']);\r\n+ \r\n $message->setNumber($userData['number']);\r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setEmail\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n \n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":46},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setUserId($userData['user_id']);\r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n- $message->setNumber($userData['number']);\r\n+ \r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 899 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setNumber\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n \n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":47},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setName($userData['name']);\r\n $message->setEmail($userData['email']);\r\n $message->setNumber($userData['number']);\r\n- $message->setMessage($userData['message']);\r\n+ \r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 903 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.050, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_valida_setters\r\nExpectation failed for method name is \"setMessage\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => true, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":50},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n- return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n+ return ['success' => true, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 451 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":50},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $message->setMessage($userData['message']);\r\n if ($message->exists($this->conn)) {\r\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\r\n- return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n+ return ['message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 452 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_ya_enviado\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:111\r\n\r\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => false, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n- return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n+ return ['success' => false, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\r\n }\r\n if ($message->save($this->conn)) {\r\n- return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\r\n+ return ['message' => '\u00a1Mensaje enviado exitosamente!'];\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_exitoso\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:56\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => true, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n+ return ['success' => true, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 542 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 9, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\r\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n+ return ['message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_error_al_guardar\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:132\r\n\r\nERRORS!\r\nTests: 5, Assertions: 8, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => true, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 11, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['success' => false, 'message' => $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\r\nFailed asserting that 'Error de conexi\u00f3n' contains \"Error al enviar mensaje\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:153\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n \/\/ Agregar estos m\u00e9todos protegidos para permitir el mock en las pruebas\n protected function createUser()\n {\n return new User();\n }\n protected function createMessage()\n {\n return new Message();\n }\n public function sendMessage($userData)\n {\n try {\n \/\/ Validar que todos los campos requeridos existan\n if (!isset($userData['user_id']) || !isset($userData['name']) || !isset($userData['email']) || !isset($userData['message'])) {\n return ['success' => false, 'message' => 'Faltan campos requeridos'];\n }\n \/\/ Modificar la creaci\u00f3n de User y Message\n $user = $this->createUser();\n $user->setId($userData['user_id']);\n if (!$user->exists($this->conn)) {\n return ['success' => false, 'message' => 'Usuario no encontrado'];\n }\n $message = $this->createMessage();\n $message->setUserId($userData['user_id']);\n $message->setName($userData['name']);\n $message->setEmail($userData['email']);\n $message->setNumber($userData['number']);\n $message->setMessage($userData['message']);\n if ($message->exists($this->conn)) {\n \/\/ Asumiendo que existe un m\u00e9todo exists() en Message\n return ['success' => false, 'message' => '\u00a1Mensaje ya enviado!'];\n }\n if ($message->save($this->conn)) {\n return ['success' => true, 'message' => '\u00a1Mensaje enviado exitosamente!'];\n }\n \/\/ A\u00f1adir log espec\u00edfico si save() falla\n error_log(\"Error en save(): Fall\u00f3 al guardar el mensaje para usuario ID: \" . $userData['user_id']);\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\n } catch (\\Exception $e) {\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\n return ['message' => 'Error al enviar mensaje: ' . $e->getMessage()];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ContactController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al enviar mensaje'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al enviar mensaje: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n+ return ['message' => 'Error al enviar mensaje: ' . $e->getMessage()];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ContactControllerTest::enviar_mensaje_lanza_excepcion\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ContactControllerTest.php:152\r\n\r\nERRORS!\r\nTests: 6, Assertions: 10, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getOrders($userId)\r\n+ protected function getOrders($userId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.......E\r\nNotice: fwrite(): Write of 778 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::manejar_error_base_datos_en_obtener_pedidos\r\nError: Call to protected method Controllers\\OrderController::getOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:231\r\n\r\nERRORS!\r\nTests: 8, Assertions: 28, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":45},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function updatePaymentStatus($orderId, $status)\r\n+ protected function updatePaymentStatus($orderId, $status)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":48},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\r\n- return $stmt->execute([$status, $orderId]);\r\n+ return $stmt->execute([$orderId]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n protected function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":55},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function deleteOrder($orderId)\r\n+ protected function deleteOrder($orderId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":58},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\r\n- return $stmt->execute([$orderId]);\r\n+ return $stmt->execute([]);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n protected function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":65},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function getAllOrders()\r\n+ protected function getAllOrders()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 568 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nError: Call to protected method Controllers\\OrderController::getAllOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:195\r\n\r\nERRORS!\r\nTests: 6, Assertions: 19, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n \n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":68},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n- $stmt->execute();\r\n+ \r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 572 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 24, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach (array() as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\r\n $stmt->execute();\r\n $orders = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 568 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:197\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":72},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setUserId($row['user_id']);\r\n+ \r\n $order->setName($row['name']);\r\n $order->setEmail($row['email']);\r\n $order->setMethod($row['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 568 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_pedidos\r\nFailed asserting that null is identical to 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:199\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":88},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function createOrder($userData, $userId)\r\n+ protected function createOrder($userData, $userId)\r\n {\r\n try {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n \n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":91},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $order = new Order();\r\n- $order->setUserId($userId);\r\n+ \r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n \n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":92},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $order = new Order();\r\n $order->setUserId($userId);\r\n- $order->setName($userData['name']);\r\n+ \r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);\r\n $order->setMethod($userData['method']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n \n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":93},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order = new Order();\r\n $order->setUserId($userId);\r\n $order->setName($userData['name']);\r\n- $order->setNumber($userData['number']);\r\n+ \r\n $order->setEmail($userData['email']);\r\n $order->setMethod($userData['method']);\r\n \/\/ Obtener productos del carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n \n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":94},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setUserId($userId);\r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n- $order->setEmail($userData['email']);\r\n+ \r\n $order->setMethod($userData['method']);\r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n \n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":95},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setName($userData['name']);\r\n $order->setNumber($userData['number']);\r\n $order->setEmail($userData['email']);\r\n- $order->setMethod($userData['method']);\r\n+ \r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if (empty($cartItems)) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => true, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":100},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if (empty($cartItems)) {\r\n- return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n+ return ['success' => true, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n \/\/ Validar productos antes de procesar\r\n foreach ($cartItems as $item) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":100},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Obtener productos del carrito\r\n $cartItems = $this->getCartItems($userId);\r\n if (empty($cartItems)) {\r\n- return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n+ return ['message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n \/\/ Validar productos antes de procesar\r\n foreach ($cartItems as $item) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach (array() as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":104},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\r\n }\r\n \/\/ Validar productos antes de procesar\r\n- foreach ($cartItems as $item) {\r\n+ foreach (array() as $item) {\r\n if (empty($item['name'])) {\r\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..................F\r\nNotice: fwrite(): Write of 1691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_total_negativo\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Error: precio inv\u00e1lido'\r\n+'Error al procesar el pedido'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:582\r\n\r\nFAILURES!\r\nTests: 19, Assertions: 79, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => true, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Validar productos antes de procesar\r\n foreach ($cartItems as $item) {\r\n if (empty($item['name'])) {\r\n- return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n+ return ['success' => true, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n }\r\n if ($item['price'] < 0) {\r\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...................F 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1792 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_vacio\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:619\r\n\r\nFAILURES!\r\nTests: 20, Assertions: 82, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":106},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Validar productos antes de procesar\r\n foreach ($cartItems as $item) {\r\n if (empty($item['name'])) {\r\n- return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n+ return ['message' => 'Error: nombre de producto inv\u00e1lido'];\r\n }\r\n if ($item['price'] < 0) {\r\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...................E 20 \/ 20 (100%)\r\nNotice: fwrite(): Write of 1788 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_con_nombre_producto_vacio\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:619\r\n\r\nERRORS!\r\nTests: 20, Assertions: 81, Errors: 1."},{"mutator":{"mutatorName":"LessThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] >= 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":108},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n if (empty($item['name'])) {\r\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\r\n }\r\n- if ($item['price'] < 0) {\r\n+ if ($item['price'] >= 0) {\r\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n \n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":140},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $order->setTotalPrice($cartTotal);\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n- $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n+ \r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() >= 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":150},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() >= 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 166 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() <= 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":150},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si la orden ya existe\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() <= 0) {\r\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:65\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => true, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":151},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n+ return ['success' => true, 'message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 1070 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:381\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 45, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":151},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\r\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\r\n+ return ['message' => '\u00a1Pedido ya realizado!'];\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........E\r\nNotice: fwrite(): Write of 1074 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido_duplicado\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:381\r\n\r\nERRORS!\r\nTests: 12, Assertions: 44, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n \n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":160},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n- $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n+ \r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":173},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Insertar nueva orden\r\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\r\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n- \/\/ Limpiar carrito\r\n- $this->clearCart($userId);\r\n+ \r\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => false, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":175},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n- return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n+ return ['success' => false, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":175},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\r\n \/\/ Limpiar carrito\r\n $this->clearCart($userId);\r\n- return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n+ return ['message' => '\u00a1Pedido realizado con \u00e9xito!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al crear orden: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al procesar el pedido'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n \n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":190},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private function clearCart($userId)\r\n {\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n }\r\n public function getUserOrders($userId)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nExpectation failed for method name is \"execute\" when invoked 4 time(s).\r\nMethod was expected to be called 4 times, actually called 3 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 4, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n protected function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":193},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n }\r\n- public function getUserOrders($userId)\r\n+ protected function getUserOrders($userId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nError: Call to protected method Controllers\\OrderController::getUserOrders() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\r\n\r\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":196},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n \n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":196},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n- $stmt->execute([$userId]);\r\n+ \r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach (array() as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":198},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\r\n $stmt->execute([$userId]);\r\n $orders = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $order = new Order();\r\n $order->setUserId($row['user_id']);\r\n $order->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:102\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n \n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":200},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $orders = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $order = new Order();\r\n- $order->setUserId($row['user_id']);\r\n+ \r\n $order->setName($row['name']);\r\n $order->setNumber($row['number']);\r\n $order->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nFailed asserting that null is identical to 1.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:104\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 7, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n protected function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":219},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function getAllProducts()\r\n+ protected function getAllProducts()\r\n {\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 841 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Controllers\\OrderController::getAllProducts() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\r\n\r\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":223},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setName($row['name']);\r\n $product->setPrice($row['price']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F\r\nNotice: fwrite(): Write of 840 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:274\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 31, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n protected function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":237},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function getAllUsers()\r\n+ protected function getAllUsers()\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Controllers\\OrderController::getAllUsers() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\r\n\r\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n \n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":240},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n- $stmt->execute();\r\n+ \r\n $users = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 914 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 40, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setId($row['id']);\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function updatePaymentStatus($orderId, $status)\n {\n try {\n $stmt = $this->conn->prepare(\"UPDATE orders SET payment_status = ? WHERE id = ?\");\n return $stmt->execute([$status, $orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar estado: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteOrder($orderId)\n {\n try {\n $stmt = $this->conn->prepare(\"DELETE FROM orders WHERE id = ?\");\n return $stmt->execute([$orderId]);\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar orden: \" . $e->getMessage());\n return false;\n }\n }\n public function getAllOrders()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `orders`\");\n $stmt->execute();\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function createOrder($userData, $userId)\n {\n try {\n $order = new Order();\n $order->setUserId($userId);\n $order->setName($userData['name']);\n $order->setNumber($userData['number']);\n $order->setEmail($userData['email']);\n $order->setMethod($userData['method']);\n \/\/ Obtener productos del carrito\n $cartItems = $this->getCartItems($userId);\n if (empty($cartItems)) {\n return ['success' => false, 'message' => 'El carrito est\u00e1 vac\u00edo'];\n }\n \/\/ Validar productos antes de procesar\n foreach ($cartItems as $item) {\n if (empty($item['name'])) {\n return ['success' => false, 'message' => 'Error: nombre de producto inv\u00e1lido'];\n }\n if ($item['price'] < 0) {\n return ['success' => false, 'message' => 'Error: precio inv\u00e1lido'];\n }\n }\n \/\/ Calcular total y preparar lista de productos\n $cartTotal = 0;\n $products = [];\n foreach ($cartItems as $item) {\n $products[] = $item['name'] . ' (' . $item['quantity'] . ')';\n $cartTotal += $item['price'] * $item['quantity'];\n }\n $totalProducts = implode(', ', $products);\n \/\/ Formatear y establecer direcci\u00f3n\n $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code'];\n \/\/ Establecer valores adicionales en el objeto Order\n $order->setAddress($address);\n $order->setTotalProducts($totalProducts);\n $order->setTotalPrice($cartTotal);\n \/\/ Verificar si la orden ya existe\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE \\r\\n name = ? AND number = ? AND email = ? AND \\r\\n method = ? AND address = ? AND \\r\\n total_products = ? AND total_price = ?\");\n $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => '\u00a1Pedido ya realizado!'];\n }\n \/\/ Insertar nueva orden\n $stmt = $this->conn->prepare(\"INSERT INTO orders \\r\\n (user_id, name, number, email, method, address, \\r\\n total_products, total_price, placed_on) \\r\\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]);\n \/\/ Limpiar carrito\n $this->clearCart($userId);\n return ['success' => true, 'message' => '\u00a1Pedido realizado con \u00e9xito!'];\n } catch (\\Exception $e) {\n error_log(\"Error al crear orden: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al procesar el pedido'];\n }\n }\n private function getCartItems($userId)\n {\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n private function clearCart($userId)\n {\n $stmt = $this->conn->prepare(\"DELETE FROM cart WHERE user_id = ?\");\n $stmt->execute([$userId]);\n }\n public function getUserOrders($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM orders WHERE user_id = ?\");\n $stmt->execute([$userId]);\n $orders = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $order = new Order();\n $order->setUserId($row['user_id']);\n $order->setName($row['name']);\n $order->setNumber($row['number']);\n $order->setEmail($row['email']);\n $order->setMethod($row['method']);\n $order->setAddress($row['address']);\n $order->setTotalProducts($row['total_products']);\n $order->setTotalPrice($row['total_price']);\n $order->setPaymentStatus($row['payment_status']);\n $order->setPlacedOn($row['placed_on']);\n $orders[] = $order;\n }\n return $orders;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener \u00f3rdenes del usuario: \" . $e->getMessage());\n return [];\n }\n }\n public function getAllProducts()\n {\n try {\n $stmt = $this->conn->query(\"SELECT * FROM `products`\");\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n public function getAllUsers()\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\n $stmt->execute();\n $users = [];\n foreach (array() as $row) {\n $user = new User();\n $user->setName($row['name']);\n $user->setEmail($row['email']);\n $user->setUserType($row['user_type']);\n $users[] = $user;\n }\n return $users;\n } catch (\\Exception $e) {\n $this->handleDatabaseError($e);\n return [];\n }\n }\n private function handleDatabaseError(\\Exception $e)\n {\n error_log(\"Error en la base de datos: \" . $e->getMessage());\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php","originalStartLine":242},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM `users`\");\r\n $stmt->execute();\r\n $users = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $user = new User();\r\n $user->setName($row['name']);\r\n $user->setEmail($row['email']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........F\r\nNotice: fwrite(): Write of 913 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nFailed asserting that an array is not empty.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:308\r\n\r\nFAILURES!\r\nTests: 10, Assertions: 36, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function getLatestProducts($limit = 6)\r\n+ protected function getLatestProducts($limit = 6)\r\n {\r\n try {\r\n $query = \"SELECT * FROM products LIMIT :limit\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nError: Call to protected method Controllers\\ProductController::getLatestProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n \n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"SELECT * FROM products LIMIT :limit\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n- $stmt->execute();\r\n+ \r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\r\n $stmt->execute();\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nUndefined array key 0\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:50\r\n\r\nERRORS!\r\nTests: 1, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n \n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":28},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n- $product->setName($row['name']);\r\n+ \r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 200 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nFailed asserting that null is identical to 'Producto Test'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:51\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n protected function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function addToCart($userId, $productData)\r\n+ protected function addToCart($userId, $productData)\r\n {\r\n try {\r\n $cart = new Cart();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n \n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":43},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $cart = new Cart();\r\n- $cart->setUserId($userId);\r\n+ \r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n \n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":44},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $cart = new Cart();\r\n $cart->setUserId($userId);\r\n- $cart->setName($productData['product_name']);\r\n+ \r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);\r\n $cart->setImage($productData['product_image']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n \n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":45},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart = new Cart();\r\n $cart->setUserId($userId);\r\n $cart->setName($productData['product_name']);\r\n- $cart->setPrice($productData['product_price']);\r\n+ \r\n $cart->setQuantity($productData['product_quantity']);\r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n \n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":46},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setUserId($userId);\r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n- $cart->setQuantity($productData['product_quantity']);\r\n+ \r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n \n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":47},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setName($productData['product_name']);\r\n $cart->setPrice($productData['product_price']);\r\n $cart->setQuantity($productData['product_quantity']);\r\n- $cart->setImage($productData['product_image']);\r\n+ \r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n- $stmt->execute([$userId, $cart->getName()]);\r\n+ $stmt->execute([$cart->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n \n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":51},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $cart->setImage($productData['product_image']);\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n- $stmt->execute([$userId, $cart->getName()]);\r\n+ \r\n if ($stmt->rowCount() > 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() >= 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":53},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() >= 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() <= 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":53},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n- if ($stmt->rowCount() > 0) {\r\n+ if ($stmt->rowCount() <= 0) {\r\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => true, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n+ return ['success' => true, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":54},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\r\n $stmt->execute([$userId, $cart->getName()]);\r\n if ($stmt->rowCount() > 0) {\r\n- return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\r\n+ return ['message' => 'El producto ya est\u00e1 en el carrito'];\r\n }\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n \n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ A\u00f1adir al carrito\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n+ \r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nExpectation failed for method name is \"execute\" when invoked 2 time(s).\r\nMethod was expected to be called 2 times, actually called 1 times.\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 9, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => false, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n- return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n+ return ['success' => false, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 267 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\r\n- return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n+ return ['message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.041, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:77\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n+ return ['success' => true, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n public function getAllProducts()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............F\r\nNotice: fwrite(): Write of 1459 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\r\n\r\nFAILURES!\r\nTests: 15, Assertions: 49, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n+ return ['message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n public function getAllProducts()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..............E\r\nNotice: fwrite(): Write of 1468 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_agregar_al_carrito\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:337\r\n\r\nERRORS!\r\nTests: 15, Assertions: 48, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n protected function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":77},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\r\n }\r\n }\r\n- public function getAllProducts()\r\n+ protected function getAllProducts()\r\n {\r\n try {\r\n $query = \"SELECT * FROM products\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nError: Call to protected method Controllers\\ProductController::getAllProducts() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:200\r\n\r\nERRORS!\r\nTests: 7, Assertions: 22, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n \n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":81},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM products\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute();\r\n+ \r\n $products = [];\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 28, Failures: 1."},{"mutator":{"mutatorName":"Foreach_","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach (array() as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":84},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute();\r\n $products = [];\r\n- foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n+ foreach (array() as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n $product->setName($row['name']);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 695 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nFailed asserting that actual size 0 matches expected size 2.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:202\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 23, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n \n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":87},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\r\n $product = new Product();\r\n $product->setId($row['id']);\r\n- $product->setName($row['name']);\r\n+ \r\n $product->setPrice($row['price']);\r\n $product->setImage($row['image']);\r\n $products[] = $product;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 699 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_todos_productos\r\nFailed asserting that null matches expected 'Producto 1'.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:204\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 25, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n protected function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":99},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function getCartItems($userId)\r\n+ protected function getCartItems($userId)\r\n {\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\r\nError: Call to protected method Controllers\\ProductController::getCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:107\r\n\r\nERRORS!\r\nTests: 3, Assertions: 9, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":103},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\r\nFailed asserting that two arrays are identical.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-Array &0 (\r\n- 0 => Array &1 (\r\n- 'id' => 1\r\n- 'name' => 'Producto Test'\r\n- 'price' => 99.99\r\n- 'quantity' => 1\r\n- 'image' => 'test.jpg'\r\n- )\r\n-)\r\n+Array &0 ()\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:109\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 10, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":103},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 350 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_items_carrito\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 12, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n protected function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":111},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return [];\r\n }\r\n }\r\n- public function updateCartQuantity($cartId, $quantity)\r\n+ protected function updateCartQuantity($cartId, $quantity)\r\n {\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":115},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$quantity, $cartId]);\r\n+ $stmt->execute([$cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":115},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$quantity, $cartId]);\r\n+ \r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => false, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":116},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$quantity, $cartId]);\r\n- return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n+ return ['success' => false, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 13, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":116},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$quantity, $cartId]);\r\n- return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n+ return ['message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 457 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::actualizar_cantidad_carrito_exitoso\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:129\r\n\r\nERRORS!\r\nTests: 4, Assertions: 12, Errors: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al actualizar cantidad: \");\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al actualizar cantidad: \");\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \");\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ error_log(\"Error al actualizar cantidad: \");\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n \n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":118},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$quantity, $cartId]);\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n+ \r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":119},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n+ return ['success' => true, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n public function deleteCartItem($cartId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":119},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n+ return ['message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n public function deleteCartItem($cartId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n protected function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":123},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\r\n }\r\n }\r\n- public function deleteCartItem($cartId)\r\n+ protected function deleteCartItem($cartId)\r\n {\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":127},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cartId]);\r\n+ $stmt->execute([]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":127},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$cartId]);\r\n+ \r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":128},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"DELETE FROM cart WHERE id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$cartId]);\r\n- return true;\r\n+ return false;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 538 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_item_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:149\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 17, Failures: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error al eliminar item: \");\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error al eliminar item: \");\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \");\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ error_log(\"Error al eliminar item: \");\r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n \n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":130},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$cartId]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n+ \r\n return false;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return true;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":131},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar item: \" . $e->getMessage());\r\n- return false;\r\n+ return true;\r\n }\r\n }\r\n public function deleteAllCartItems($userId)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n protected function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":135},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return false;\r\n }\r\n }\r\n- public function deleteAllCartItems($userId)\r\n+ protected function deleteAllCartItems($userId)\r\n {\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 630 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nError: Call to protected method Controllers\\ProductController::deleteAllCartItems() from scope Tests\\Unit\\Controllers\\ProductControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:166\r\n\r\nERRORS!\r\nTests: 6, Assertions: 19, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":139},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ $stmt->execute([]);\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n \n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":139},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n- $stmt->execute([$userId]);\r\n+ \r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return false;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":140},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $query = \"DELETE FROM cart WHERE user_id = ?\";\r\n $stmt = $this->conn->prepare($query);\r\n $stmt->execute([$userId]);\r\n- return true;\r\n+ return false;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n return false;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 635 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.031, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::eliminar_todos_items_carrito_exitoso\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:168\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 20, Failures: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return false;\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function getLatestProducts($limit = 6)\n {\n try {\n $query = \"SELECT * FROM products LIMIT :limit\";\n $stmt = $this->conn->prepare($query);\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener productos: \" . $e->getMessage());\n return [];\n }\n }\n public function addToCart($userId, $productData)\n {\n try {\n $cart = new Cart();\n $cart->setUserId($userId);\n $cart->setName($productData['product_name']);\n $cart->setPrice($productData['product_price']);\n $cart->setQuantity($productData['product_quantity']);\n $cart->setImage($productData['product_image']);\n \/\/ Verificar si el producto ya est\u00e1 en el carrito\n $stmt = $this->conn->prepare(\"SELECT * FROM cart WHERE user_id = ? AND name = ?\");\n $stmt->execute([$userId, $cart->getName()]);\n if ($stmt->rowCount() > 0) {\n return ['success' => false, 'message' => 'El producto ya est\u00e1 en el carrito'];\n }\n \/\/ A\u00f1adir al carrito\n $query = \"INSERT INTO cart (user_id, name, price, quantity, image) \\r\\n VALUES (?, ?, ?, ?, ?)\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cart->getUserId(), $cart->getName(), $cart->getPrice(), $cart->getQuantity(), $cart->getImage()]);\n return ['success' => true, 'message' => 'Producto a\u00f1adido al carrito'];\n } catch (\\Exception $e) {\n error_log(\"Error al a\u00f1adir al carrito: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al a\u00f1adir al carrito'];\n }\n }\n public function getAllProducts()\n {\n try {\n $query = \"SELECT * FROM products\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute();\n $products = [];\n foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n $product = new Product();\n $product->setId($row['id']);\n $product->setName($row['name']);\n $product->setPrice($row['price']);\n $product->setImage($row['image']);\n $products[] = $product;\n }\n return $products;\n } catch (\\Exception $e) {\n error_log(\"Error al obtener todos los productos: \" . $e->getMessage());\n return [];\n }\n }\n public function getCartItems($userId)\n {\n try {\n $query = \"SELECT * FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener items del carrito: \" . $e->getMessage());\n return [];\n }\n }\n public function updateCartQuantity($cartId, $quantity)\n {\n try {\n $query = \"UPDATE cart SET quantity = ? WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$quantity, $cartId]);\n return ['success' => true, 'message' => '\u00a1Cantidad actualizada!'];\n } catch (\\Exception $e) {\n error_log(\"Error al actualizar cantidad: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al actualizar cantidad'];\n }\n }\n public function deleteCartItem($cartId)\n {\n try {\n $query = \"DELETE FROM cart WHERE id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$cartId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar item: \" . $e->getMessage());\n return false;\n }\n }\n public function deleteAllCartItems($userId)\n {\n try {\n $query = \"DELETE FROM cart WHERE user_id = ?\";\n $stmt = $this->conn->prepare($query);\n $stmt->execute([$userId]);\n return true;\n } catch (\\Exception $e) {\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\n return true;\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php","originalStartLine":143},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return true;\r\n } catch (\\Exception $e) {\r\n error_log(\"Error al eliminar todos los items: \" . $e->getMessage());\r\n- return false;\r\n+ return true;\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.............F\r\nNotice: fwrite(): Write of 1386 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.040, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::manejo_error_al_eliminar_todos_items_carrito\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:317\r\n\r\nFAILURES!\r\nTests: 14, Assertions: 47, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n protected function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":11},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->conn = $conn;\r\n }\r\n- public function searchProducts($searchTerm)\r\n+ protected function searchProducts($searchTerm)\r\n {\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 217 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::buscar_productos_devuelve_resultados\r\nError: Call to protected method Controllers\\SearchController::searchProducts() from scope Tests\\Unit\\Controllers\\SearchControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:38\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n \n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";\r\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\r\n- $stmt->execute([$searchTerm]);\r\n+ \r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n try {\r\n $searchTerm = \"%{$searchTerm}%\";\r\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\r\n- $stmt->execute([$searchTerm]);\r\n+ $stmt->execute([]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...F\r\nNotice: fwrite(): Write of 552 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_con_parametro_vacio\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nParameter 0 for invocation PDOStatement::execute(Array ()): bool does not match expected value.\r\nFailed asserting that two arrays are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n Array (\r\n- 0 => '%%'\r\n )\r\n\r\nFAILURES!\r\nTests: 4, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"Concat","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage() . \"Error en b\u00fasqueda: \");\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ error_log($e->getMessage() . \"Error en b\u00fasqueda: \");\r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.044, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '[11-Dec-2024 23:16:41 Europe\/Berlin] Error de pruebaError en b\u00fasqueda: \\r\\n\r\n' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log($e->getMessage());\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ error_log($e->getMessage());\r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.049, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '[11-Dec-2024 23:16:41 Europe\/Berlin] Error de prueba\\r\\n\r\n' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"ConcatOperandRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \");\n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ error_log(\"Error en b\u00fasqueda: \");\r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '[11-Dec-2024 23:16:41 Europe\/Berlin] Error en b\u00fasqueda: \\r\\n\r\n' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"FunctionCallRemoval","originalSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\n return [];\n }\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n public function searchProducts($searchTerm)\n {\n try {\n $searchTerm = \"%{$searchTerm}%\";\n $stmt = $this->conn->prepare(\"SELECT * FROM products WHERE name LIKE ?\");\n $stmt->execute([$searchTerm]);\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n \n return [];\n }\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\SearchController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$searchTerm]);\r\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\r\n } catch (\\Exception $e) {\r\n- error_log(\"Error en b\u00fasqueda: \" . $e->getMessage());\r\n+ \r\n return [];\r\n }\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F 5 \/ 5 (100%)\r\nNotice: fwrite(): Write of 655 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\SearchControllerTest::test_search_products_maneja_error_y_logging\r\nFailed asserting that '' contains \"Error en b\u00fasqueda: Error de prueba\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\SearchControllerTest.php:117\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 8, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, []);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function hashPassword($password)\r\n {\r\n- return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n+ return password_hash($password, PASSWORD_BCRYPT, []);\r\n }\r\n private function verifyPassword($password, $hashedPassword)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 1133 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.463, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\r\nFailed asserting that '$2y$10$N7gH5\/6HoxJt6GSTuNb3X.S6XZ3HPrrJ7CqcMAllxeu8fXeSIe3xe' contains \"$2y$12$\".\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:244\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 23, Failures: 1."},{"mutator":{"mutatorName":"FunctionCall","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n return null;\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function hashPassword($password)\r\n {\r\n- return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n+ password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\r\n+ return null;\r\n }\r\n private function verifyPassword($password, $hashedPassword)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........F\r\nNotice: fwrite(): Write of 1137 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:01.220, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::verifica_hash_password_con_costo_correcto\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:243\r\n\r\nFAILURES!\r\nTests: 12, Assertions: 22, Failures: 1."},{"mutator":{"mutatorName":"FunctionCall","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n password_verify($password, $hashedPassword);\n return null;\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n private function verifyPassword($password, $hashedPassword)\r\n {\r\n- return password_verify($password, $hashedPassword);\r\n+ password_verify($password, $hashedPassword);\r\n+ return null;\r\n }\r\n public function registerUser($userData)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.339, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:73\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n protected function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return password_verify($password, $hashedPassword);\r\n }\r\n- public function registerUser($userData)\r\n+ protected function registerUser($userData)\r\n {\r\n try {\r\n $user = new User();","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 190 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\r\nError: Call to protected method Controllers\\UserController::registerUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:42\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => true, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);\r\n if ($stmt->fetch()) {\r\n- return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n+ return ['success' => true, 'message' => 'El correo ya est\u00e1 registrado'];\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....F\r\nNotice: fwrite(): Write of 550 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.334, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:128\r\n\r\nFAILURES!\r\nTests: 5, Assertions: 10, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\r\n $stmt->execute([$user->getEmail()]);\r\n if ($stmt->fetch()) {\r\n- return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\r\n+ return ['message' => 'El correo ya est\u00e1 registrado'];\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 549 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.350, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::registro_falla_con_email_existente\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:128\r\n\r\nERRORS!\r\nTests: 5, Assertions: 9, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n \n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n- $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n+ \r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................E 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2898 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:01.281, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\r\nUndefined array key 3\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:641\r\n\r\nERRORS!\r\nTests: 33, Assertions: 60, Errors: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n- $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n+ $stmt->execute([$user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n................................E 33 \/ 33 (100%)\r\nNotice: fwrite(): Write of 2925 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:03.411, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::register_mantiene_tipo_usuario_por_defecto\r\nUndefined array key 3\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:641\r\n\r\nERRORS!\r\nTests: 33, Assertions: 60, Errors: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => false, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":49},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n- return ['success' => true, 'message' => 'Registro exitoso!'];\r\n+ return ['success' => false, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nF\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.235, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\r\nFailed asserting that false is identical to true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:48\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 1, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":49},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n \/\/ Usar password_hash en lugar de md5\r\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\r\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\r\n- return ['success' => true, 'message' => 'Registro exitoso!'];\r\n+ return ['message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el registro'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 191 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.243, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_registrarse\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:48\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":52},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el registro'];\r\n+ return ['success' => true, 'message' => 'Error en el registro'];\r\n }\r\n }\r\n public function loginUser($email, $password)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....F\r\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.338, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:146\r\n\r\nFAILURES!\r\nTests: 6, Assertions: 12, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":52},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => true, 'message' => 'Registro exitoso!'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en registro: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el registro'];\r\n+ return ['message' => 'Error en el registro'];\r\n }\r\n }\r\n public function loginUser($email, $password)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 615 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_registro\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:146\r\n\r\nERRORS!\r\nTests: 6, Assertions: 11, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n protected function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":56},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error en el registro'];\r\n }\r\n }\r\n- public function loginUser($email, $password)\r\n+ protected function loginUser($email, $password)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 276 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.296, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nError: Call to protected method Controllers\\UserController::loginUser() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:71\r\n\r\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n \n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n- $stmt->execute([$email]);\r\n+ \r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($user && $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 688 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Error en el inicio de sesi\u00f3n'\r\n+'Correo o contrase\u00f1a incorrectos'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:161\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":59},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n- $stmt->execute([$email]);\r\n+ $stmt->execute([]);\r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n if ($user && $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........................F\r\nNotice: fwrite(): Write of 2462 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:02.392, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::login_falla_con_parametros_vacios\r\nFailed asserting that two strings are equal.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Error en el inicio de sesi\u00f3n'\r\n+'Correo o contrase\u00f1a incorrectos'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:516\r\n\r\nFAILURES!\r\nTests: 28, Assertions: 48, Failures: 1."},{"mutator":{"mutatorName":"LogicalAnd","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user || $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":62},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\r\n $stmt->execute([$email]);\r\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\r\n- if ($user && $this->verifyPassword($password, $user['password'])) {\r\n+ if ($user || $this->verifyPassword($password, $user['password'])) {\r\n $_SESSION['user_id'] = $user['id'];\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.297, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\r\nFailed asserting that two strings are identical.\r\n--- Expected\r\n+++ Actual\r\n@@ @@\r\n-'Correo o contrase\u00f1a incorrectos'\r\n+'Error en el inicio de sesi\u00f3n'\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:89\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 6, Failures: 1."},{"mutator":{"mutatorName":"TrueValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => false, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":67},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];\r\n $_SESSION['user_email'] = $user['email'];\r\n- return ['success' => true, 'user_type' => $user['user_type']];\r\n+ return ['success' => false, 'user_type' => $user['user_type']];\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.F\r\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nFailed asserting that false is true.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:73\r\n\r\nFAILURES!\r\nTests: 2, Assertions: 3, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":67},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_name'] = $user['name'];\r\n $_SESSION['user_type'] = $user['user_type'];\r\n $_SESSION['user_email'] = $user['email'];\r\n- return ['success' => true, 'user_type' => $user['user_type']];\r\n+ return ['user_type' => $user['user_type']];\r\n }\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 277 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.361, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::usuario_puede_iniciar_sesion\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:73\r\n\r\nERRORS!\r\nTests: 2, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => true, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_email'] = $user['email'];\r\n return ['success' => true, 'user_type' => $user['user_type']];\r\n }\r\n- return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n+ return ['success' => true, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..F\r\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.362, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\r\nFailed asserting that true is identical to false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:88\r\n\r\nFAILURES!\r\nTests: 3, Assertions: 5, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":70},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $_SESSION['user_email'] = $user['email'];\r\n return ['success' => true, 'user_type' => $user['user_type']];\r\n }\r\n- return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n+ return ['message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 400 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.362, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::inicio_sesion_falla_con_credenciales_incorrectas\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:88\r\n\r\nERRORS!\r\nTests: 3, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"FalseValue","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => true, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n+ return ['success' => true, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }\r\n public function logout()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......F\r\nNotice: fwrite(): Write of 687 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.340, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\r\nFailed asserting that true is false.\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:160\r\n\r\nFAILURES!\r\nTests: 7, Assertions: 14, Failures: 1."},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":73},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\r\n } catch (\\Exception $e) {\r\n error_log(\"Error en login: \" . $e->getMessage());\r\n- return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\r\n+ return ['message' => 'Error en el inicio de sesi\u00f3n'];\r\n }\r\n }\r\n public function logout()","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 691 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.353, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::manejo_error_en_login\r\nUndefined array key \"success\"\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:160\r\n\r\nERRORS!\r\nTests: 7, Assertions: 13, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n protected function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":99},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\r\n }\r\n }\r\n- public function getUserById($userId)\r\n+ protected function getUserById($userId)\r\n {\r\n try {\r\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 459 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.349, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::puede_obtener_usuario_por_id\r\nError: Call to protected method Controllers\\UserController::getUserById() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:106\r\n\r\nERRORS!\r\nTests: 4, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n public function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","mutatedSourceCode":"conn = $conn;\n }\n private function hashPassword($password)\n {\n return password_hash($password, PASSWORD_BCRYPT, ['cost' => self::HASH_COST]);\n }\n private function verifyPassword($password, $hashedPassword)\n {\n return password_verify($password, $hashedPassword);\n }\n public function registerUser($userData)\n {\n try {\n $user = new User();\n $user->setName($userData['name']);\n $user->setEmail($userData['email']);\n $user->setUserType($userData['user_type'] ?? 'user');\n \/\/ Verificar si el correo ya existe\n $stmt = $this->conn->prepare(\"SELECT id FROM users WHERE email = ?\");\n $stmt->execute([$user->getEmail()]);\n if ($stmt->fetch()) {\n return ['success' => false, 'message' => 'El correo ya est\u00e1 registrado'];\n }\n \/\/ Usar password_hash en lugar de md5\n $stmt = $this->conn->prepare(\"INSERT INTO users (name, email, password, user_type) \\r\\n VALUES (?, ?, ?, ?)\");\n $stmt->execute([$user->getName(), $user->getEmail(), $this->hashPassword($userData['password']), $user->getUserType()]);\n return ['success' => true, 'message' => 'Registro exitoso!'];\n } catch (\\Exception $e) {\n error_log(\"Error en registro: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el registro'];\n }\n }\n public function loginUser($email, $password)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT * FROM users WHERE email = ?\");\n $stmt->execute([$email]);\n $user = $stmt->fetch(\\PDO::FETCH_ASSOC);\n if ($user && $this->verifyPassword($password, $user['password'])) {\n $_SESSION['user_id'] = $user['id'];\n $_SESSION['user_name'] = $user['name'];\n $_SESSION['user_type'] = $user['user_type'];\n $_SESSION['user_email'] = $user['email'];\n return ['success' => true, 'user_type' => $user['user_type']];\n }\n return ['success' => false, 'message' => 'Correo o contrase\u00f1a incorrectos'];\n } catch (\\Exception $e) {\n error_log(\"Error en login: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error en el inicio de sesi\u00f3n'];\n }\n }\n public function logout()\n {\n try {\n \/\/ Asegurarse de que la sesi\u00f3n est\u00e1 iniciada\n if (session_status() === PHP_SESSION_NONE) {\n session_start();\n }\n \/\/ Limpiar todas las variables de sesi\u00f3n\n $_SESSION = array();\n \/\/ Destruir la sesi\u00f3n\n session_destroy();\n \/\/ Redireccionar al login\n header('location: ..\/auth\/login.php');\n exit;\n } catch (\\Exception $e) {\n error_log(\"Error en logout: \" . $e->getMessage());\n return ['success' => false, 'message' => 'Error al cerrar sesi\u00f3n'];\n }\n }\n public function getUserById($userId)\n {\n try {\n $stmt = $this->conn->prepare(\"SELECT id, name, email, user_type FROM users WHERE id = ?\");\n $stmt->execute([$userId]);\n return $stmt->fetch(\\PDO::FETCH_ASSOC);\n } catch (\\Exception $e) {\n error_log(\"Error al obtener usuario: \" . $e->getMessage());\n return null;\n }\n }\n \/\/ Alias para mantener compatibilidad\n protected function register($userData)\n {\n return $this->registerUser($userData);\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\UserController.php","originalStartLine":111},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n }\r\n }\r\n \/\/ Alias para mantener compatibilidad\r\n- public function register($userData)\r\n+ protected function register($userData)\r\n {\r\n return $this->registerUser($userData);\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 941 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.553, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\UserControllerTest::verificar_alias_register\r\nError: Call to protected method Controllers\\UserController::register() from scope Tests\\Unit\\Controllers\\UserControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\UserControllerTest.php:206\r\n\r\nERRORS!\r\nTests: 10, Assertions: 18, Errors: 1."},{"mutator":{"mutatorName":"DecrementInteger","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getUserId()\r\n+ protected function getUserId()\r\n {\r\n return $this->userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getUserId() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:63\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->userId;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":16},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getPrice()\r\n+ protected function getPrice()\r\n {\r\n return $this->price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.025, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getPrice() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:65\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n protected function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->price;\r\n }\r\n- public function getQuantity()\r\n+ protected function getQuantity()\r\n {\r\n return $this->quantity;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getQuantity() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:66\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n protected function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->quantity;\r\n }\r\n- public function getImage()\r\n+ protected function getImage()\r\n {\r\n return $this->image;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 268 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::agregar_al_carrito\r\nError: Call to protected method Models\\Cart::getImage() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:67\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:75\r\n\r\nERRORS!\r\nTests: 2, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n protected function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->image;\r\n }\r\n \/\/ Setters\r\n- public function setUserId($userId)\r\n+ protected function setUserId($userId)\r\n {\r\n $this->userId = $userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userId = $userId;\r\n }\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setPrice($price)\r\n+ protected function setPrice($price)\r\n {\r\n $this->price = $price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n protected function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->price = $price;\r\n }\r\n- public function setQuantity($quantity)\r\n+ protected function setQuantity($quantity)\r\n {\r\n $this->quantity = $quantity;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getQuantity()\n {\n return $this->quantity;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setQuantity($quantity)\n {\n $this->quantity = $quantity;\n }\n protected function setImage($image)\n {\n $this->image = $image;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Cart.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->quantity = $quantity;\r\n }\r\n- public function setImage($image)\r\n+ protected function setImage($image)\r\n {\r\n $this->image = $image;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ProductControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":13},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $number;\r\n private $message;\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\r\nError: Call to protected method Models\\Message::getId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:28\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getUserId()\r\n+ protected function getUserId()\r\n {\r\n return $this->userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 256 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\r\nError: Call to protected method Models\\Message::getUserId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:36\r\n\r\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":15},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->userId;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.020, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\r\nError: Call to protected method Models\\Message::getName() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:44\r\n\r\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":16},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getEmail()\r\n+ protected function getEmail()\r\n {\r\n return $this->email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.020, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\r\nError: Call to protected method Models\\Message::getEmail() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:52\r\n\r\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n protected function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->email;\r\n }\r\n- public function getNumber()\r\n+ protected function getNumber()\r\n {\r\n return $this->number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.019, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\r\nError: Call to protected method Models\\Message::getNumber() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:60\r\n\r\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n protected function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->number;\r\n }\r\n- public function getMessage()\r\n+ protected function getMessage()\r\n {\r\n return $this->message;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\r\nError: Call to protected method Models\\Message::getMessage() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:68\r\n\r\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n protected function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->message;\r\n }\r\n \/\/ Setters\r\n- public function setUserId($userId)\r\n+ protected function setUserId($userId)\r\n {\r\n $this->userId = $userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.023, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_user_id\r\nError: Call to protected method Models\\Message::setUserId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:35\r\n\r\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userId = $userId;\r\n }\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 324 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_name\r\nError: Call to protected method Models\\Message::setName() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:43\r\n\r\nERRORS!\r\nTests: 3, Assertions: 2, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setEmail($email)\r\n+ protected function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 396 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_email\r\nError: Call to protected method Models\\Message::setEmail() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:51\r\n\r\nERRORS!\r\nTests: 4, Assertions: 3, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n protected function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->email = $email;\r\n }\r\n- public function setNumber($number)\r\n+ protected function setNumber($number)\r\n {\r\n $this->number = $number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n....E\r\nNotice: fwrite(): Write of 469 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.020, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_number\r\nError: Call to protected method Models\\Message::setNumber() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:59\r\n\r\nERRORS!\r\nTests: 5, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n protected function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->number = $number;\r\n }\r\n- public function setMessage($message)\r\n+ protected function setMessage($message)\r\n {\r\n $this->message = $message;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.....E\r\nNotice: fwrite(): Write of 543 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.022, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_message\r\nError: Call to protected method Models\\Message::setMessage() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:67\r\n\r\nERRORS!\r\nTests: 6, Assertions: 5, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n protected function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->message = $message;\r\n }\r\n- public function exists($conn)\r\n+ protected function exists($conn)\r\n {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\r\nError: Call to protected method Models\\Message::exists() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:128\r\n\r\nERRORS!\r\nTests: 9, Assertions: 12, Errors: 1."},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n \n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\r\n $stmt = $conn->prepare($sql);\r\n- $stmt->execute([$this->userId, $this->message]);\r\n+ \r\n return $stmt->rowCount() > 0;\r\n }\r\n public function save($conn)","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........F 9 \/ 9 (100%)\r\nNotice: fwrite(): Write of 746 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.025, Memory: 8.00 MB\r\n\r\nThere was 1 failure:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::maneja_error_al_verificar_existencia\r\nExpectation failed for method name is \"execute\" when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n\r\nFAILURES!\r\nTests: 9, Assertions: 15, Failures: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n protected function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":34},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt->execute([$this->userId, $this->message]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n- public function save($conn)\r\n+ protected function save($conn)\r\n {\r\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\r\n $stmt = $conn->prepare($sql);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 590 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.027, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_guardar_mensaje\r\nError: Call to protected method Models\\Message::save() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:88\r\n\r\nERRORS!\r\nTests: 7, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getMessage()\n {\n return $this->message;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setMessage($message)\n {\n $this->message = $message;\n }\n public function exists($conn)\n {\n $sql = \"SELECT id FROM message WHERE user_id = ? AND message = ?\";\n $stmt = $conn->prepare($sql);\n $stmt->execute([$this->userId, $this->message]);\n return $stmt->rowCount() > 0;\n }\n public function save($conn)\n {\n $sql = \"INSERT INTO message (user_id, name, email, number, message) VALUES (?, ?, ?, ?, ?)\";\n $stmt = $conn->prepare($sql);\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\n }\n protected function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Message.php","originalStartLine":46},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $stmt = $conn->prepare($sql);\r\n return $stmt->execute([$this->userId, $this->name, $this->email, $this->number, $this->message]);\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 175 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.021, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\MessageTest::puede_establecer_y_obtener_id\r\nError: Call to protected method Models\\Message::setId() from scope Tests\\Unit\\Models\\MessageTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\MessageTest.php:27\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $placedOn;\r\n private $paymentStatus;\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\r\nError: Call to protected method Models\\Order::getId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:326\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\r\n\r\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getUserId()\r\n+ protected function getUserId()\r\n {\r\n return $this->userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getUserId() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:161\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":20},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->userId;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getName() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:141\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getNumber()\r\n+ protected function getNumber()\r\n {\r\n return $this->number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getNumber() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:142\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n protected function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->number;\r\n }\r\n- public function getEmail()\r\n+ protected function getEmail()\r\n {\r\n return $this->email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getEmail() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:143\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n protected function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->email;\r\n }\r\n- public function getMethod()\r\n+ protected function getMethod()\r\n {\r\n return $this->method;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.029, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getMethod() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:144\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n protected function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->method;\r\n }\r\n- public function getAddress()\r\n+ protected function getAddress()\r\n {\r\n return $this->address;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.037, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getAddress() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:145\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n protected function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":25},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->address;\r\n }\r\n- public function getTotalProducts()\r\n+ protected function getTotalProducts()\r\n {\r\n return $this->totalProducts;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getTotalProducts() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:146\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n protected function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":26},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->totalProducts;\r\n }\r\n- public function getTotalPrice()\r\n+ protected function getTotalPrice()\r\n {\r\n return $this->totalPrice;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::getTotalPrice() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:147\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n protected function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":28},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->placedOn;\r\n }\r\n- public function getPaymentStatus()\r\n+ protected function getPaymentStatus()\r\n {\r\n return $this->paymentStatus;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 343 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateOrderStatus\r\nError: Call to protected method Models\\Order::getPaymentStatus() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:326\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:81\r\n\r\nERRORS!\r\nTests: 3, Assertions: 7, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n protected function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":31},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->paymentStatus;\r\n }\r\n \/\/ Setters\r\n- public function setUserId($userId)\r\n+ protected function setUserId($userId)\r\n {\r\n $this->userId = $userId;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":32},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userId = $userId;\r\n }\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setNumber($number)\r\n+ protected function setNumber($number)\r\n {\r\n $this->number = $number;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n protected function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":34},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->number = $number;\r\n }\r\n- public function setEmail($email)\r\n+ protected function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n protected function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->email = $email;\r\n }\r\n- public function setMethod($method)\r\n+ protected function setMethod($method)\r\n {\r\n $this->method = $method;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\OrderControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n protected function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->method = $method;\r\n }\r\n- public function setAddress($address)\r\n+ protected function setAddress($address)\r\n {\r\n $this->address = $address;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.030, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::setAddress() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:130\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n protected function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":37},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->address = $address;\r\n }\r\n- public function setTotalProducts($totalProducts)\r\n+ protected function setTotalProducts($totalProducts)\r\n {\r\n $this->totalProducts = $totalProducts;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.028, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::setTotalProducts() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:131\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n protected function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":38},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->totalProducts = $totalProducts;\r\n }\r\n- public function setTotalPrice($totalPrice)\r\n+ protected function setTotalPrice($totalPrice)\r\n {\r\n $this->totalPrice = $totalPrice;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 167 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::crear_pedido\r\nError: Call to protected method Models\\Order::setTotalPrice() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:132\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:63\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n protected function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":39},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->totalPrice = $totalPrice;\r\n }\r\n- public function setPaymentStatus($status)\r\n+ protected function setPaymentStatus($status)\r\n {\r\n $this->paymentStatus = $status;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 256 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nError: Call to protected method Models\\Order::setPaymentStatus() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:208\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\r\n\r\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n protected function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":40},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->paymentStatus = $status;\r\n }\r\n- public function setPlacedOn($placedOn)\r\n+ protected function setPlacedOn($placedOn)\r\n {\r\n $this->placedOn = $placedOn;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 257 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_pedidos_usuario\r\nError: Call to protected method Models\\Order::setPlacedOn() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:209\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:100\r\n\r\nERRORS!\r\nTests: 2, Assertions: 4, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","mutatedSourceCode":"id;\n }\n public function getUserId()\n {\n return $this->userId;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getNumber()\n {\n return $this->number;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getMethod()\n {\n return $this->method;\n }\n public function getAddress()\n {\n return $this->address;\n }\n public function getTotalProducts()\n {\n return $this->totalProducts;\n }\n public function getTotalPrice()\n {\n return $this->totalPrice;\n }\n public function getPlacedOn()\n {\n return $this->placedOn;\n }\n public function getPaymentStatus()\n {\n return $this->paymentStatus;\n }\n \/\/ Setters\n public function setUserId($userId)\n {\n $this->userId = $userId;\n }\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setNumber($number)\n {\n $this->number = $number;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setMethod($method)\n {\n $this->method = $method;\n }\n public function setAddress($address)\n {\n $this->address = $address;\n }\n public function setTotalProducts($totalProducts)\n {\n $this->totalProducts = $totalProducts;\n }\n public function setTotalPrice($totalPrice)\n {\n $this->totalPrice = $totalPrice;\n }\n public function setPaymentStatus($status)\n {\n $this->paymentStatus = $status;\n }\n public function setPlacedOn($placedOn)\n {\n $this->placedOn = $placedOn;\n }\n protected function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Order.php","originalStartLine":42},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->placedOn = $placedOn;\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n return $this;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 183 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetDashboardData\r\nError: Call to protected method Models\\Order::setId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:43\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:24\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:37\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":11},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n private $price;\r\n private $image;\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...........E\r\nNotice: fwrite(): Write of 955 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testUpdateProduct\r\nError: Call to protected method Models\\Product::getId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:266\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:241\r\n\r\nERRORS!\r\nTests: 12, Assertions: 28, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":12},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:276\r\n\r\nERRORS!\r\nTests: 9, Assertions: 32, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":13},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getPrice()\r\n+ protected function getPrice()\r\n {\r\n return $this->price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 336 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nError: Call to protected method Models\\Product::getPrice() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:133\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\r\n\r\nERRORS!\r\nTests: 3, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n protected function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":14},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->price;\r\n }\r\n- public function getImage()\r\n+ protected function getImage()\r\n {\r\n return $this->image;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n..E\r\nNotice: fwrite(): Write of 335 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.032, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testAddProductSuccessfully\r\nError: Call to protected method Models\\Product::getImage() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:133\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:66\r\n\r\nERRORS!\r\nTests: 3, Assertions: 6, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->image;\r\n }\r\n \/\/ Setters\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 837 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.034, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::setName() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:225\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\r\n\r\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setPrice($price)\r\n+ protected function setPrice($price)\r\n {\r\n $this->price = $price;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 841 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.043, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::setPrice() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:226\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\r\n\r\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n protected function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->price = $price;\r\n }\r\n- public function setImage($image)\r\n+ protected function setImage($image)\r\n {\r\n $this->image = $image;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n........E\r\nNotice: fwrite(): Write of 841 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.035, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_productos\r\nError: Call to protected method Models\\Product::setImage() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:227\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:272\r\n\r\nERRORS!\r\nTests: 9, Assertions: 30, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n public function setId($id)\n {\n $this->id = $id;\n }\n}","mutatedSourceCode":"id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getPrice()\n {\n return $this->price;\n }\n public function getImage()\n {\n return $this->image;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setPrice($price)\n {\n $this->price = $price;\n }\n public function setImage($image)\n {\n $this->image = $image;\n }\n protected function setId($id)\n {\n $this->id = $id;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\Product.php","originalStartLine":21},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->image = $image;\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 201 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.026, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\ProductControllerTest::obtener_productos_recientes\r\nError: Call to protected method Models\\Product::setId() from scope Controllers\\ProductController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\ProductController.php:27\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\ProductControllerTest.php:47\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n protected function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":16},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->userType = 'user';\r\n }\r\n \/\/ Getters\r\n- public function getId()\r\n+ protected function getId()\r\n {\r\n return $this->id;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n......E\r\nNotice: fwrite(): Write of 608 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testDeleteUser\r\nError: Call to protected method Models\\User::getId() from scope Controllers\\AdminController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\AdminController.php:373\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:154\r\n\r\nERRORS!\r\nTests: 7, Assertions: 17, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n protected function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":17},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->id;\r\n }\r\n- public function getName()\r\n+ protected function getName()\r\n {\r\n return $this->name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.038, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::getName() from scope Tests\\Unit\\Controllers\\OrderControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:310\r\n\r\nERRORS!\r\nTests: 10, Assertions: 37, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n protected function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":18},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->name;\r\n }\r\n- public function getEmail()\r\n+ protected function getEmail()\r\n {\r\n return $this->email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n...E\r\nNotice: fwrite(): Write of 404 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.033, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\AdminControllerTest::testGetAllUsers\r\nError: Call to protected method Models\\User::getEmail() from scope Tests\\Unit\\Controllers\\AdminControllerTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\AdminControllerTest.php:115\r\n\r\nERRORS!\r\nTests: 4, Assertions: 13, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n protected function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":19},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n return $this->email;\r\n }\r\n- public function getUserType()\r\n+ protected function getUserType()\r\n {\r\n return $this->userType;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nE\r\nNotice: fwrite(): Write of 193 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.025, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\UserTest::verifica_constructor_inicializa_user_type\r\nError: Call to protected method Models\\User::getUserType() from scope Tests\\Unit\\Models\\UserTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:26\r\n\r\nERRORS!\r\nTests: 1, Assertions: 0, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n protected function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":22},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n return $this->userType;\r\n }\r\n \/\/ Setters\r\n- public function setName($name)\r\n+ protected function setName($name)\r\n {\r\n $this->name = $name;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.039, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::setName() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:244\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\r\n\r\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n protected function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":23},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->name = $name;\r\n }\r\n- public function setEmail($email)\r\n+ protected function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 914 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.036, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::setEmail() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:245\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\r\n\r\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n protected function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":24},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->email = $email;\r\n }\r\n- public function setPassword($password)\r\n+ protected function setPassword($password)\r\n {\r\n $this->password = password_hash($password, PASSWORD_DEFAULT);\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.E\r\nNotice: fwrite(): Write of 249 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.024, Memory: 8.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Models\\UserTest::verifica_password_es_hasheado\r\nError: Call to protected method Models\\User::setPassword() from scope Tests\\Unit\\Models\\UserTest\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Models\\UserTest.php:33\r\n\r\nERRORS!\r\nTests: 2, Assertions: 1, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n protected function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":27},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->password = password_hash($password, PASSWORD_DEFAULT);\r\n }\r\n- public function setUserType($userType)\r\n+ protected function setUserType($userType)\r\n {\r\n $this->userType = $userType;\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\n.........E\r\nNotice: fwrite(): Write of 918 bytes failed with errno=13 Permission denied in C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\vendor\\infection\\include-interceptor\\src\\IncludeInterceptor.php on line 359\r\n\r\n\r\nTime: 00:00.042, Memory: 10.00 MB\r\n\r\nThere was 1 error:\r\n\r\n1) Tests\\Unit\\Controllers\\OrderControllerTest::obtener_todos_usuarios\r\nError: Call to protected method Models\\User::setUserType() from scope Controllers\\OrderController\r\n\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Controllers\\OrderController.php:246\r\nC:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Unit\\Controllers\\OrderControllerTest.php:306\r\n\r\nERRORS!\r\nTests: 10, Assertions: 35, Errors: 1."},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n protected function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":28},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $this->userType = $userType;\r\n }\r\n- public function setId($id)\r\n+ protected function setId($id)\r\n {\r\n $this->id = $id;\r\n return $this;","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"This","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return null;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":30},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function setId($id)\r\n {\r\n $this->id = $id;\r\n- return $this;\r\n+ return null;\r\n }\r\n public function exists($conn)\r\n {","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"PublicVisibility","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n protected function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":33},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n $this->id = $id;\r\n return $this;\r\n }\r\n- public function exists($conn)\r\n+ protected function exists($conn)\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"ArrayItemRemoval","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([]);\n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function exists($conn)\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n- $stmt->execute([$this->id]);\r\n+ $stmt->execute([]);\r\n return $stmt->rowCount() > 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"MethodCallRemoval","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n \n return $stmt->rowCount() > 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":35},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n public function exists($conn)\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n- $stmt->execute([$this->id]);\r\n+ \r\n return $stmt->rowCount() > 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThan","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() >= 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);\r\n- return $stmt->rowCount() > 0;\r\n+ return $stmt->rowCount() >= 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"},{"mutator":{"mutatorName":"GreaterThanNegotiation","originalSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() > 0;\n }\n}","mutatedSourceCode":"userType = 'user';\n }\n \/\/ Getters\n public function getId()\n {\n return $this->id;\n }\n public function getName()\n {\n return $this->name;\n }\n public function getEmail()\n {\n return $this->email;\n }\n public function getUserType()\n {\n return $this->userType;\n }\n \/\/ Setters\n public function setName($name)\n {\n $this->name = $name;\n }\n public function setEmail($email)\n {\n $this->email = $email;\n }\n public function setPassword($password)\n {\n $this->password = password_hash($password, PASSWORD_DEFAULT);\n }\n public function setUserType($userType)\n {\n $this->userType = $userType;\n }\n public function setId($id)\n {\n $this->id = $id;\n return $this;\n }\n public function exists($conn)\n {\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\n $stmt->execute([$this->id]);\n return $stmt->rowCount() <= 0;\n }\n}","originalFilePath":"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\src\\Models\\User.php","originalStartLine":36},"diff":"--- Original\r\n+++ New\r\n@@ @@\r\n {\r\n $stmt = $conn->prepare(\"SELECT id FROM users WHERE id = ?\");\r\n $stmt->execute([$this->id]);\r\n- return $stmt->rowCount() > 0;\r\n+ return $stmt->rowCount() <= 0;\r\n }\r\n }","processOutput":"Warning: Module \"openssl\" is already loaded in Unknown on line 0\r\nPHPUnit 9.6.22 by Sebastian Bergmann and contributors.\r\n\r\nTest file \"C:\\Users\\ASUS\\Desktop\\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\\tests\\Mutation\\ContactControllerMutationTest.php\" not found"}],"errored":[],"syntaxErrors":[],"uncovered":[],"ignored":[]} \ No newline at end of file diff --git a/reports/mutations/infection.log b/reports/mutations/infection.log index f0403191..beb8594b 100644 --- a/reports/mutations/infection.log +++ b/reports/mutations/infection.log @@ -1,14 +1,29 @@ Escaped mutants: ================ -1) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:38 [M] MethodCallRemoval +1) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:43 [M] MethodCallRemoval --- Original +++ New @@ @@ - private function getTotalPendings() + $total = 0; + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + $order = new Order(); +- $order->setId($row['id']); ++ + $order->setTotalPrice($row['total_price']); + $total += $order->getTotalPrice(); + } + + +2) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:55 [M] MethodCallRemoval + +--- Original ++++ New +@@ @@ + private function getTotalCompleted() { - $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'pendiente'"); + $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'completado'"); - $stmt->execute(); + $total = 0; @@ -16,7 +31,7 @@ Escaped mutants: $order = new Order(); -2) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:42 [M] MethodCallRemoval +3) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:59 [M] MethodCallRemoval --- Original +++ New @@ -31,352 +46,488 @@ Escaped mutants: } -3) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:51 [M] MethodCallRemoval +4) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:117 [M] MethodCallRemoval --- Original +++ New @@ @@ - private function getTotalCompleted() - { - $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'completado'"); -- $stmt->execute(); -+ - $total = 0; - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - $order = new Order(); + try { + $product = new Product(); + $product->setName($postData['name']); +- $product->setPrice($postData['price']); ++ + $product->setImage($files['image']['name']); + // Verificar si el producto ya existe + $stmt = $this->conn->prepare("SELECT name FROM `products` WHERE name = ?"); -4) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:55 [M] MethodCallRemoval +5) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:118 [M] MethodCallRemoval --- Original +++ New @@ @@ - $total = 0; - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - $order = new Order(); -- $order->setId($row['id']); + $product = new Product(); + $product->setName($postData['name']); + $product->setPrice($postData['price']); +- $product->setImage($files['image']['name']); + - $order->setTotalPrice($row['total_price']); - $total += $order->getTotalPrice(); - } + // Verificar si el producto ya existe + $stmt = $this->conn->prepare("SELECT name FROM `products` WHERE name = ?"); + $stmt->execute([$product->getName()]); -5) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:65 [M] MethodCallRemoval +6) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:125 [M] FalseValue --- Original +++ New @@ @@ - { - $query = "SELECT COUNT(*) as count FROM `orders`"; - $stmt = $this->conn->prepare($query); -- $stmt->execute(); -+ - return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - } - private function getProductsCount() + $stmt = $this->conn->prepare("SELECT name FROM `products` WHERE name = ?"); + $stmt->execute([$product->getName()]); + if ($stmt->rowCount() > 0) { +- return ['success' => false, 'message' => 'El producto ya existe']; ++ return ['success' => true, 'message' => 'El producto ya existe']; + } + if ($files['image']['size'] > 2000000) { + return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; -6) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:72 [M] MethodCallRemoval +7) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:125 [M] ArrayItemRemoval --- Original +++ New @@ @@ - { - $query = "SELECT COUNT(*) as count FROM `products`"; - $stmt = $this->conn->prepare($query); -- $stmt->execute(); -+ - return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - } - private function getUsersCount() + $stmt = $this->conn->prepare("SELECT name FROM `products` WHERE name = ?"); + $stmt->execute([$product->getName()]); + if ($stmt->rowCount() > 0) { +- return ['success' => false, 'message' => 'El producto ya existe']; ++ return ['message' => 'El producto ya existe']; + } + if ($files['image']['size'] > 2000000) { + return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; -7) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:79 [M] MethodCallRemoval +8) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:128 [M] GreaterThan --- Original +++ New @@ @@ - { - $query = "SELECT COUNT(*) as count FROM `users` WHERE user_type = 'user'"; - $stmt = $this->conn->prepare($query); -- $stmt->execute(); -+ - return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - } - private function getAdminsCount() + if ($stmt->rowCount() > 0) { + return ['success' => false, 'message' => 'El producto ya existe']; + } +- if ($files['image']['size'] > 2000000) { ++ if ($files['image']['size'] >= 2000000) { + return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; + } + $stmt = $this->conn->prepare("INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)"); -8) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:86 [M] MethodCallRemoval +9) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:129 [M] FalseValue --- Original +++ New @@ @@ - { - $query = "SELECT COUNT(*) as count FROM `users` WHERE user_type = 'admin'"; - $stmt = $this->conn->prepare($query); -- $stmt->execute(); -+ - return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - } - private function getTotalAccounts() + return ['success' => false, 'message' => 'El producto ya existe']; + } + if ($files['image']['size'] > 2000000) { +- return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; ++ return ['success' => true, 'message' => 'El tamaño de la imagen es demasiado grande']; + } + $stmt = $this->conn->prepare("INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)"); + if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) { -9) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:93 [M] MethodCallRemoval +10) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:129 [M] ArrayItemRemoval --- Original +++ New @@ @@ - { - $query = "SELECT COUNT(*) as count FROM `users`"; - $stmt = $this->conn->prepare($query); -- $stmt->execute(); -+ - return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - } - private function getMessagesCount() + return ['success' => false, 'message' => 'El producto ya existe']; + } + if ($files['image']['size'] > 2000000) { +- return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; ++ return ['message' => 'El tamaño de la imagen es demasiado grande']; + } + $stmt = $this->conn->prepare("INSERT INTO `products`(name, price, image) VALUES(?, ?, ?)"); + if ($stmt->execute([$product->getName(), $product->getPrice(), $product->getImage()])) { -10) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:100 [M] MethodCallRemoval +11) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:147 [M] ArrayItemRemoval --- Original +++ New @@ @@ - { - $query = "SELECT COUNT(*) as count FROM `message`"; - $stmt = $this->conn->prepare($query); -- $stmt->execute(); -+ - return $stmt->fetch(\PDO::FETCH_ASSOC)['count']; - } - private function handleDatabaseError($e) + try { + // Obtener información de la imagen + $stmt = $this->conn->prepare("SELECT image FROM `products` WHERE id = ?"); +- $stmt->execute([$id]); ++ $stmt->execute([]); + $image_data = $stmt->fetch(\PDO::FETCH_ASSOC); + if ($image_data) { + $imagePath = self::UPLOAD_PATH . $image_data['image']; -11) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:105 [M] Concat +12) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:147 [M] MethodCallRemoval --- Original +++ New @@ @@ - } - private function handleDatabaseError($e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ error_log($e->getMessage() . "Error en la base de datos: "); - throw new \Exception("Error al procesar la solicitud"); - } - public function addProduct($postData, $files) + try { + // Obtener información de la imagen + $stmt = $this->conn->prepare("SELECT image FROM `products` WHERE id = ?"); +- $stmt->execute([$id]); ++ + $image_data = $stmt->fetch(\PDO::FETCH_ASSOC); + if ($image_data) { + $imagePath = self::UPLOAD_PATH . $image_data['image']; -12) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:105 [M] ConcatOperandRemoval +13) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:153 [M] FunctionCallRemoval --- Original +++ New @@ @@ - } - private function handleDatabaseError($e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ error_log($e->getMessage()); - throw new \Exception("Error al procesar la solicitud"); - } - public function addProduct($postData, $files) + if ($image_data) { + $imagePath = self::UPLOAD_PATH . $image_data['image']; + if (file_exists($imagePath)) { +- unlink($imagePath); ++ + } + } + $stmt = $this->conn->prepare("DELETE FROM `products` WHERE id = ?"); -13) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:105 [M] ConcatOperandRemoval +14) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:190 [M] Throw_ --- Original +++ New @@ @@ - } - private function handleDatabaseError($e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ error_log("Error en la base de datos: "); - throw new \Exception("Error al procesar la solicitud"); - } - public function addProduct($postData, $files) + $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ?"); + $stmt->execute([$imageName]); + if (!$stmt->fetch()) { +- throw new \Exception('Archivo no encontrado en la base de datos'); ++ new \Exception('Archivo no encontrado en la base de datos'); + } + return self::UPLOAD_PATH . $imageName; + } catch (\Exception $e) { -14) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:105 [M] FunctionCallRemoval +15) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:209 [M] ArrayItemRemoval --- Original +++ New @@ @@ - } - private function handleDatabaseError($e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ - throw new \Exception("Error al procesar la solicitud"); - } - public function addProduct($postData, $files) + } + // Verificar en la base de datos + $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ? LIMIT 1"); +- $stmt->execute([$imageName]); ++ $stmt->execute([]); + $result = $stmt->fetch(\PDO::FETCH_ASSOC); + if (!$result) { + return false; -15) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:172 [M] LogicalOr +16) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:209 [M] MethodCallRemoval --- Original +++ New @@ @@ - { - try { - // Validar el nombre del archivo -- if (empty($imageName) || !is_string($imageName)) { -+ if (empty($imageName) && !is_string($imageName)) { - throw new \Exception('Nombre de archivo inválido'); } - // Obtener y validar la extensión + // Verificar en la base de datos + $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ? LIMIT 1"); +- $stmt->execute([$imageName]); ++ + $result = $stmt->fetch(\PDO::FETCH_ASSOC); + if (!$result) { + return false; -16) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:177 [M] UnwrapStrToLower +17) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:213 [M] FalseValue --- Original +++ New @@ @@ - throw new \Exception('Nombre de archivo inválido'); - } - // Obtener y validar la extensión -- $extension = strtolower(pathinfo($imageName, PATHINFO_EXTENSION)); -+ $extension = pathinfo($imageName, PATHINFO_EXTENSION); - if (!in_array($extension, self::ALLOWED_EXTENSIONS)) { - throw new \Exception('Tipo de archivo no permitido'); + $stmt->execute([$imageName]); + $result = $stmt->fetch(\PDO::FETCH_ASSOC); + if (!$result) { +- return false; ++ return true; } + // Construir y validar la ruta + $fullPath = realpath(self::UPLOAD_PATH . $result['image']); -17) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:184 [M] ArrayItemRemoval +18) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:217 [M] Concat --- Original +++ New @@ @@ + return false; } - // Verificar que el archivo existe en la base de datos - $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ?"); -- $stmt->execute([$imageName]); -+ $stmt->execute([]); - if (!$stmt->fetch()) { - throw new \Exception('Archivo no encontrado en la base de datos'); + // Construir y validar la ruta +- $fullPath = realpath(self::UPLOAD_PATH . $result['image']); ++ $fullPath = realpath($result['image'] . self::UPLOAD_PATH); + $uploadDir = realpath(self::UPLOAD_PATH); + // Verificar que el archivo está dentro del directorio permitido + if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) { + + +19) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:217 [M] ConcatOperandRemoval + +--- Original ++++ New +@@ @@ + return false; } + // Construir y validar la ruta +- $fullPath = realpath(self::UPLOAD_PATH . $result['image']); ++ $fullPath = realpath($result['image']); + $uploadDir = realpath(self::UPLOAD_PATH); + // Verificar que el archivo está dentro del directorio permitido + if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) { -18) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:184 [M] MethodCallRemoval +20) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:217 [M] ConcatOperandRemoval --- Original +++ New @@ @@ + return false; } - // Verificar que el archivo existe en la base de datos - $stmt = $this->conn->prepare("SELECT image FROM products WHERE image = ?"); -- $stmt->execute([$imageName]); + // Construir y validar la ruta +- $fullPath = realpath(self::UPLOAD_PATH . $result['image']); ++ $fullPath = realpath(self::UPLOAD_PATH); + $uploadDir = realpath(self::UPLOAD_PATH); + // Verificar que el archivo está dentro del directorio permitido + if ($fullPath === false || strpos($fullPath, $uploadDir) !== 0) { + + +21) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:240 [M] MethodCallRemoval + +--- Original ++++ New +@@ @@ + { + try { + $product = new Product(); +- $product->setId($postData['update_p_id']); + - if (!$stmt->fetch()) { - throw new \Exception('Archivo no encontrado en la base de datos'); - } + $product->setName($postData['update_name']); + $product->setPrice($postData['update_price']); + if (!empty($files['update_image']['name'])) { -19) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:189 [M] Concat +22) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:241 [M] MethodCallRemoval --- Original +++ New @@ @@ - if (!$stmt->fetch()) { - throw new \Exception('Archivo no encontrado en la base de datos'); - } -- return self::UPLOAD_PATH . $imageName; -+ return $imageName . self::UPLOAD_PATH; - } catch (\Exception $e) { - error_log("Error en getSecureImagePath: " . $e->getMessage()); - return false; + try { + $product = new Product(); + $product->setId($postData['update_p_id']); +- $product->setName($postData['update_name']); ++ + $product->setPrice($postData['update_price']); + if (!empty($files['update_image']['name'])) { + if ($files['update_image']['size'] > 2000000) { -20) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:189 [M] ConcatOperandRemoval +23) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:242 [M] MethodCallRemoval --- Original +++ New @@ @@ - if (!$stmt->fetch()) { - throw new \Exception('Archivo no encontrado en la base de datos'); - } -- return self::UPLOAD_PATH . $imageName; -+ return $imageName; - } catch (\Exception $e) { - error_log("Error en getSecureImagePath: " . $e->getMessage()); - return false; + $product = new Product(); + $product->setId($postData['update_p_id']); + $product->setName($postData['update_name']); +- $product->setPrice($postData['update_price']); ++ + if (!empty($files['update_image']['name'])) { + if ($files['update_image']['size'] > 2000000) { + return ['success' => false, 'message' => 'El tamaño de la imagen es demasiado grande']; -21) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:191 [M] Concat +24) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:251 [M] MethodCallRemoval --- Original +++ New @@ @@ - } - return self::UPLOAD_PATH . $imageName; - } catch (\Exception $e) { -- error_log("Error en getSecureImagePath: " . $e->getMessage()); -+ error_log($e->getMessage() . "Error en getSecureImagePath: "); - return false; - } - } + } + // Eliminar imagen anterior de forma segura + if (!empty($postData['update_old_image'])) { +- $this->handleImageDelete($postData['update_old_image']); ++ + } + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); -22) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:191 [M] ConcatOperandRemoval +25) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:256 [M] Concat --- Original +++ New @@ @@ - } - return self::UPLOAD_PATH . $imageName; - } catch (\Exception $e) { -- error_log("Error en getSecureImagePath: " . $e->getMessage()); -+ error_log($e->getMessage()); - return false; - } - } + } + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); +- $newImageName = uniqid() . '.' . $extension; ++ $newImageName = '.' . uniqid() . $extension; + $product->setImage($newImageName); + // Subir nueva imagen + move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); -23) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:191 [M] ConcatOperandRemoval +26) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:256 [M] ConcatOperandRemoval --- Original +++ New @@ @@ - } - return self::UPLOAD_PATH . $imageName; - } catch (\Exception $e) { -- error_log("Error en getSecureImagePath: " . $e->getMessage()); -+ error_log("Error en getSecureImagePath: "); - return false; - } - } + } + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); +- $newImageName = uniqid() . '.' . $extension; ++ $newImageName = '.' . $extension; + $product->setImage($newImageName); + // Subir nueva imagen + move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); -24) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:191 [M] FunctionCallRemoval +27) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:256 [M] ConcatOperandRemoval --- Original +++ New @@ @@ - } - return self::UPLOAD_PATH . $imageName; - } catch (\Exception $e) { -- error_log("Error en getSecureImagePath: " . $e->getMessage()); -+ - return false; - } - } + } + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); +- $newImageName = uniqid() . '.' . $extension; ++ $newImageName = uniqid() . $extension; + $product->setImage($newImageName); + // Subir nueva imagen + move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); -25) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:209 [M] FalseValue +28) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:256 [M] Concat --- Original +++ New @@ @@ - $stmt->execute([$imageName]); - $result = $stmt->fetch(\PDO::FETCH_ASSOC); - if (!$result) { -- return false; -+ return true; + } + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); +- $newImageName = uniqid() . '.' . $extension; ++ $newImageName = uniqid() . $extension . '.'; + $product->setImage($newImageName); + // Subir nueva imagen + move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); + + +29) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:256 [M] ConcatOperandRemoval + +--- Original ++++ New +@@ @@ + } + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); +- $newImageName = uniqid() . '.' . $extension; ++ $newImageName = uniqid() . '.'; + $product->setImage($newImageName); + // Subir nueva imagen + move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); + + +30) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:257 [M] MethodCallRemoval + +--- Original ++++ New +@@ @@ + // Generar nombre único para la nueva imagen + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); + $newImageName = uniqid() . '.' . $extension; +- $product->setImage($newImageName); ++ + // Subir nueva imagen + move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); + $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); + + +31) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:260 [M] FunctionCallRemoval + +--- Original ++++ New +@@ @@ + $extension = strtolower(pathinfo($files['update_image']['name'], PATHINFO_EXTENSION)); + $newImageName = uniqid() . '.' . $extension; + $product->setImage($newImageName); +- // Subir nueva imagen +- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); ++ + $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); + $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; + } else { + + +32) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:262 [M] Concat + +--- Original ++++ New +@@ @@ + $newImageName = uniqid() . '.' . $extension; + $product->setImage($newImageName); + // Subir nueva imagen +- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); ++ move_uploaded_file($files['update_image']['tmp_name'], $newImageName . self::UPLOAD_PATH); + $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); + $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; + } else { + + +33) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:262 [M] ConcatOperandRemoval + +--- Original ++++ New +@@ @@ + $newImageName = uniqid() . '.' . $extension; + $product->setImage($newImageName); + // Subir nueva imagen +- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); ++ move_uploaded_file($files['update_image']['tmp_name'], $newImageName); + $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); + $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; + } else { + + +34) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:262 [M] ConcatOperandRemoval + +--- Original ++++ New +@@ @@ + $newImageName = uniqid() . '.' . $extension; + $product->setImage($newImageName); + // Subir nueva imagen +- move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH . $newImageName); ++ move_uploaded_file($files['update_image']['tmp_name'], self::UPLOAD_PATH); + $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ?, image = ? WHERE id = ?"); + $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; + } else { + + +35) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:269 [M] ArrayItemRemoval + +--- Original ++++ New +@@ @@ + $params = [$product->getName(), $product->getPrice(), $product->getImage(), $product->getId()]; + } else { + $stmt = $this->conn->prepare("UPDATE `products` SET name = ?, price = ? WHERE id = ?"); +- $params = [$product->getName(), $product->getPrice(), $product->getId()]; ++ $params = [$product->getPrice(), $product->getId()]; } - // Construir y validar la ruta - $fullPath = realpath(self::UPLOAD_PATH . $result['image']); + if ($stmt->execute($params)) { + return ['success' => true, 'message' => 'Producto actualizado exitosamente']; -26) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:284 [M] MethodCallRemoval +36) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:288 [M] MethodCallRemoval --- Original +++ New @@ -391,22 +542,7 @@ Escaped mutants: $product->setImage($row['image']); -27) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:287 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $product->setId($row['id']); - $product->setName($row['name']); - $product->setPrice($row['price']); -- $product->setImage($row['image']); -+ - $products[] = $product; - } - return $products; - - -28) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:295 [M] MethodCallRemoval +37) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:299 [M] MethodCallRemoval --- Original +++ New @@ -421,7 +557,7 @@ Escaped mutants: $order = new Order(); -29) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:299 [M] MethodCallRemoval +38) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:303 [M] MethodCallRemoval --- Original +++ New @@ -436,7 +572,7 @@ Escaped mutants: $order->setName($row['name']); -30) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:300 [M] MethodCallRemoval +39) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:304 [M] MethodCallRemoval --- Original +++ New @@ -451,7 +587,7 @@ Escaped mutants: $order->setNumber($row['number']); -31) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:301 [M] MethodCallRemoval +40) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:305 [M] MethodCallRemoval --- Original +++ New @@ -466,7 +602,7 @@ Escaped mutants: $order->setEmail($row['email']); -32) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:303 [M] MethodCallRemoval +41) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:307 [M] MethodCallRemoval --- Original +++ New @@ -481,7 +617,7 @@ Escaped mutants: $order->setTotalProducts($row['total_products']); -33) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:304 [M] MethodCallRemoval +42) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:308 [M] MethodCallRemoval --- Original +++ New @@ -496,7 +632,7 @@ Escaped mutants: $order->setTotalPrice($row['total_price']); -34) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:305 [M] MethodCallRemoval +43) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:309 [M] MethodCallRemoval --- Original +++ New @@ -511,7 +647,7 @@ Escaped mutants: $order->setMethod($row['method']); -35) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:306 [M] MethodCallRemoval +44) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:310 [M] MethodCallRemoval --- Original +++ New @@ -526,7 +662,7 @@ Escaped mutants: $order->setPaymentStatus($row['payment_status']); -36) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:308 [M] MethodCallRemoval +45) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:312 [M] MethodCallRemoval --- Original +++ New @@ -541,22 +677,7 @@ Escaped mutants: } -37) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:309 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $order->setTotalProducts($row['total_products']); - $order->setTotalPrice($row['total_price']); - $order->setMethod($row['method']); -- $order->setPaymentStatus($row['payment_status']); -+ - $orders[] = $order; - } - return $orders; - - -38) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:318 [M] MethodCallRemoval +46) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:322 [M] MethodCallRemoval --- Original +++ New @@ -571,82 +692,22 @@ Escaped mutants: return $stmt->execute([$order->getPaymentStatus(), $order->getId()]); -39) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:319 [M] MethodCallRemoval +47) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:349 [M] MethodCallRemoval --- Original +++ New @@ @@ + { try { - $order = new Order(); - $order->setId($orderId); -- $order->setPaymentStatus($status); -+ - $stmt = $this->conn->prepare("UPDATE `orders` SET payment_status = ? WHERE id = ?"); - return $stmt->execute([$order->getPaymentStatus(), $order->getId()]); - } catch (\PDOException $e) { - - -40) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:322 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - $order->setId($orderId); - $order->setPaymentStatus($status); - $stmt = $this->conn->prepare("UPDATE `orders` SET payment_status = ? WHERE id = ?"); -- return $stmt->execute([$order->getPaymentStatus(), $order->getId()]); -+ return $stmt->execute([$order->getId()]); - } catch (\PDOException $e) { - $this->handleDatabaseError($e); - return false; - - -41) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:332 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - { - try { - $order = new Order(); -- $order->setId($orderId); -+ - $stmt = $this->conn->prepare("DELETE FROM `orders` WHERE id = ?"); - return $stmt->execute([$order->getId()]); - } catch (\PDOException $e) { - - -42) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:335 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - $order = new Order(); - $order->setId($orderId); - $stmt = $this->conn->prepare("DELETE FROM `orders` WHERE id = ?"); -- return $stmt->execute([$order->getId()]); -+ return $stmt->execute([]); - } catch (\PDOException $e) { - $this->handleDatabaseError($e); - return false; - - -43) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:345 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - { - try { - $stmt = $this->conn->prepare("SELECT * FROM `users`"); -- $stmt->execute(); + $stmt = $this->conn->prepare("SELECT * FROM `users`"); +- $stmt->execute(); + $users = []; foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $user = new User(); -44) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:350 [M] MethodCallRemoval +48) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:354 [M] MethodCallRemoval --- Original +++ New @@ -661,52 +722,7 @@ Escaped mutants: $user->setUserType($row['user_type']); -45) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:353 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $user->setId($row['id']); - $user->setName($row['name']); - $user->setEmail($row['email']); -- $user->setUserType($row['user_type']); -+ - $users[] = $user; - } - return $users; - - -46) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:366 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - { - try { - $user = new User(); -- $user->setId($userId); -+ - $stmt = $this->conn->prepare("DELETE FROM `users` WHERE id = ?"); - return $stmt->execute([$user->getId()]); - } catch (\PDOException $e) { - - -47) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:369 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - $user = new User(); - $user->setId($userId); - $stmt = $this->conn->prepare("DELETE FROM `users` WHERE id = ?"); -- return $stmt->execute([$user->getId()]); -+ return $stmt->execute([]); - } catch (\PDOException $e) { - $this->handleDatabaseError($e); - return false; - - -48) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:382 [M] MethodCallRemoval +49) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:386 [M] MethodCallRemoval --- Original +++ New @@ -721,7 +737,7 @@ Escaped mutants: $message->setName($row['name']); -49) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:383 [M] MethodCallRemoval +50) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:387 [M] MethodCallRemoval --- Original +++ New @@ -736,52 +752,7 @@ Escaped mutants: $message->setEmail($row['email']); -50) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:385 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $message->setId($row['id']); - $message->setUserId($row['user_id']); - $message->setMessage($row['message']); -- $message->setName($row['name']); -+ - $message->setEmail($row['email']); - $message->setNumber($row['number']); - $messages[] = $message; - - -51) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:387 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $message->setMessage($row['message']); - $message->setName($row['name']); - $message->setEmail($row['email']); -- $message->setNumber($row['number']); -+ - $messages[] = $message; - } - return $messages; - - -52) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\AdminController.php:401 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - try { - $query = "DELETE FROM `message` WHERE id = ?"; - $stmt = $this->conn->prepare($query); -- return $stmt->execute([$messageId]); -+ return $stmt->execute([]); - } catch (\PDOException $e) { - $this->handleDatabaseError($e); - return false; - - -53) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] Concat +51) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] Concat --- Original +++ New @@ -796,7 +767,7 @@ Escaped mutants: error_log("Error al enviar mensaje: " . $e->getMessage()); -54) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] ConcatOperandRemoval +52) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] ConcatOperandRemoval --- Original +++ New @@ -811,7 +782,7 @@ Escaped mutants: error_log("Error al enviar mensaje: " . $e->getMessage()); -55) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] ConcatOperandRemoval +53) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] ConcatOperandRemoval --- Original +++ New @@ -826,7 +797,7 @@ Escaped mutants: error_log("Error al enviar mensaje: " . $e->getMessage()); -56) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] FunctionCallRemoval +54) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:58 [M] FunctionCallRemoval --- Original +++ New @@ -842,7 +813,7 @@ Escaped mutants: error_log("Error al enviar mensaje: " . $e->getMessage()); -57) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] Concat +55) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] Concat --- Original +++ New @@ -858,7 +829,7 @@ Escaped mutants: } -58) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] ConcatOperandRemoval +56) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] ConcatOperandRemoval --- Original +++ New @@ -874,7 +845,7 @@ Escaped mutants: } -59) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] ConcatOperandRemoval +57) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] ConcatOperandRemoval --- Original +++ New @@ -890,7 +861,7 @@ Escaped mutants: } -60) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] FunctionCallRemoval +58) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:61 [M] FunctionCallRemoval --- Original +++ New @@ -906,7 +877,7 @@ Escaped mutants: } -61) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:62 [M] Concat +59) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:62 [M] Concat --- Original +++ New @@ -921,7 +892,7 @@ Escaped mutants: } -62) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:62 [M] ConcatOperandRemoval +60) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ContactController.php:62 [M] ConcatOperandRemoval --- Original +++ New @@ -936,7 +907,7 @@ Escaped mutants: } -63) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:40 [M] MethodCallRemoval +61) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:40 [M] MethodCallRemoval --- Original +++ New @@ -951,7 +922,7 @@ Escaped mutants: } -64) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:73 [M] MethodCallRemoval +62) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:73 [M] MethodCallRemoval --- Original +++ New @@ -966,7 +937,7 @@ Escaped mutants: $order->setAddress($row['address']); -65) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:74 [M] MethodCallRemoval +63) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:74 [M] MethodCallRemoval --- Original +++ New @@ -981,7 +952,7 @@ Escaped mutants: $order->setTotalProducts($row['total_products']); -66) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:75 [M] MethodCallRemoval +64) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:75 [M] MethodCallRemoval --- Original +++ New @@ -996,7 +967,7 @@ Escaped mutants: $order->setTotalPrice($row['total_price']); -67) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:76 [M] MethodCallRemoval +65) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:76 [M] MethodCallRemoval --- Original +++ New @@ -1011,7 +982,7 @@ Escaped mutants: $orders[] = $order; -68) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:77 [M] MethodCallRemoval +66) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:77 [M] MethodCallRemoval --- Original +++ New @@ -1026,7 +997,7 @@ Escaped mutants: } -69) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:78 [M] MethodCallRemoval +67) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:78 [M] MethodCallRemoval --- Original +++ New @@ -1041,12 +1012,27 @@ Escaped mutants: return $orders; -70) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:104 [M] DecrementInteger +68) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:108 [M] LessThan --- Original +++ New @@ @@ - return ['success' => false, 'message' => 'El carrito está vacío']; + if (empty($item['name'])) { + return ['success' => false, 'message' => 'Error: nombre de producto inválido']; + } +- if ($item['price'] < 0) { ++ if ($item['price'] <= 0) { + return ['success' => false, 'message' => 'Error: precio inválido']; + } + } + + +69) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:114 [M] DecrementInteger + +--- Original ++++ New +@@ @@ + } } // Calcular total y preparar lista de productos - $cartTotal = 0; @@ -1056,7 +1042,7 @@ Escaped mutants: $products[] = $item['name'] . ' (' . $item['quantity'] . ')'; -71) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:106 [M] Foreach_ +70) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:116 [M] Foreach_ --- Original +++ New @@ -1071,7 +1057,7 @@ Escaped mutants: } -72) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] Concat +71) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] Concat --- Original +++ New @@ -1086,7 +1072,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -73) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] ConcatOperandRemoval +72) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] ConcatOperandRemoval --- Original +++ New @@ -1101,7 +1087,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -74) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] ConcatOperandRemoval +73) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] ConcatOperandRemoval --- Original +++ New @@ -1116,7 +1102,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -75) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] Concat +74) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] Concat --- Original +++ New @@ -1131,7 +1117,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -76) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] ConcatOperandRemoval +75) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] ConcatOperandRemoval --- Original +++ New @@ -1146,7 +1132,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -77) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] Concat +76) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] Concat --- Original +++ New @@ -1161,7 +1147,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -78) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:107 [M] ConcatOperandRemoval +77) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:117 [M] ConcatOperandRemoval --- Original +++ New @@ -1176,187 +1162,7 @@ Escaped mutants: $totalProducts = implode(', ', $products); -79) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:108 [M] Multiplication - ---- Original -+++ New -@@ @@ - $products = []; - foreach ($cartItems as $item) { - $products[] = $item['name'] . ' (' . $item['quantity'] . ')'; -- $cartTotal += $item['price'] * $item['quantity']; -+ $cartTotal += $item['price'] / $item['quantity']; - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección - - -80) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:108 [M] Assignment - ---- Original -+++ New -@@ @@ - $products = []; - foreach ($cartItems as $item) { - $products[] = $item['name'] . ' (' . $item['quantity'] . ')'; -- $cartTotal += $item['price'] * $item['quantity']; -+ $cartTotal = $item['price'] * $item['quantity']; - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección - - -81) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:108 [M] PlusEqual - ---- Original -+++ New -@@ @@ - $products = []; - foreach ($cartItems as $item) { - $products[] = $item['name'] . ' (' . $item['quantity'] . ')'; -- $cartTotal += $item['price'] * $item['quantity']; -+ $cartTotal -= $item['price'] * $item['quantity']; - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección - - -82) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = $userData['flat'] . 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -83) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -84) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -85) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . ', ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -86) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -87) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . $userData['street'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -88) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -89) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -90) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -91) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat +78) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] Concat --- Original +++ New @@ -1371,7 +1177,7 @@ Escaped mutants: $order->setTotalProducts($totalProducts); -92) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval +79) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] ConcatOperandRemoval --- Original +++ New @@ -1386,7 +1192,7 @@ Escaped mutants: $order->setTotalProducts($totalProducts); -93) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat +80) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] Concat --- Original +++ New @@ -1401,97 +1207,7 @@ Escaped mutants: $order->setTotalProducts($totalProducts); -94) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -95) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -96) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -97) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -98) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -99) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] Concat - ---- Original -+++ New -@@ @@ - } - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección -- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - '; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -100) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:113 [M] ConcatOperandRemoval +81) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] ConcatOperandRemoval --- Original +++ New @@ -1500,445 +1216,284 @@ Escaped mutants: $totalProducts = implode(', ', $products); // Formatear y establecer dirección - $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -+ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - '; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); - - -101) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:120 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $totalProducts = implode(', ', $products); - // Formatear y establecer dirección - $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; -- // Establecer valores adicionales en el objeto Order -- $order->setAddress($address); -+ - $order->setTotalProducts($totalProducts); - $order->setTotalPrice($cartTotal); - // Verificar si la orden ya existe - - -102) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:121 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); -- $order->setTotalProducts($totalProducts); -+ - $order->setTotalPrice($cartTotal); - // Verificar si la orden ya existe - $stmt = $this->conn->prepare("SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?"); - - -103) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:122 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - // Establecer valores adicionales en el objeto Order - $order->setAddress($address); - $order->setTotalProducts($totalProducts); -- $order->setTotalPrice($cartTotal); -+ - // Verificar si la orden ya existe - $stmt = $this->conn->prepare("SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?"); - $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]); - - -104) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:130 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - $order->setTotalPrice($cartTotal); - // Verificar si la orden ya existe - $stmt = $this->conn->prepare("SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?"); -- $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]); -+ $stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]); - if ($stmt->rowCount() > 0) { - return ['success' => false, 'message' => '¡Pedido ya realizado!']; - } - - -105) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:150 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - } - // Insertar nueva orden - $stmt = $this->conn->prepare("INSERT INTO orders \r\n (user_id, name, number, email, method, address, \r\n total_products, total_price, placed_on) \r\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); -- $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]); -+ $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]); - // Limpiar carrito - $this->clearCart($userId); - return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; - - -106) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:167 [M] Concat - ---- Original -+++ New -@@ @@ - $this->clearCart($userId); - return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; - } catch (\Exception $e) { -- error_log("Error al crear orden: " . $e->getMessage()); -+ error_log($e->getMessage() . "Error al crear orden: "); - return ['success' => false, 'message' => 'Error al procesar el pedido']; - } - } - - -107) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:167 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - $this->clearCart($userId); - return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; - } catch (\Exception $e) { -- error_log("Error al crear orden: " . $e->getMessage()); -+ error_log($e->getMessage()); - return ['success' => false, 'message' => 'Error al procesar el pedido']; - } - } - - -108) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:167 [M] ConcatOperandRemoval - ---- Original -+++ New -@@ @@ - $this->clearCart($userId); - return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; - } catch (\Exception $e) { -- error_log("Error al crear orden: " . $e->getMessage()); -+ error_log("Error al crear orden: "); - return ['success' => false, 'message' => 'Error al procesar el pedido']; - } - } - - -109) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:167 [M] FunctionCallRemoval - ---- Original -+++ New -@@ @@ - $this->clearCart($userId); - return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; - } catch (\Exception $e) { -- error_log("Error al crear orden: " . $e->getMessage()); -+ - return ['success' => false, 'message' => 'Error al procesar el pedido']; - } - } - - -110) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:180 [M] ArrayItemRemoval - ---- Original -+++ New -@@ @@ - private function clearCart($userId) - { - $stmt = $this->conn->prepare("DELETE FROM cart WHERE user_id = ?"); -- $stmt->execute([$userId]); -+ $stmt->execute([]); - } - public function getUserOrders($userId) - { - - -111) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:191 [M] MethodCallRemoval - ---- Original -+++ New -@@ @@ - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - $order = new Order(); - $order->setUserId($row['user_id']); -- $order->setName($row['name']); -+ - $order->setNumber($row['number']); - $order->setEmail($row['email']); - $order->setMethod($row['method']); ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ' - ' . $userData['pin_code']; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -112) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:192 [M] MethodCallRemoval +82) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] Concat --- Original +++ New @@ @@ - $order = new Order(); - $order->setUserId($row['user_id']); - $order->setName($row['name']); -- $order->setNumber($row['number']); -+ - $order->setEmail($row['email']); - $order->setMethod($row['method']); - $order->setAddress($row['address']); + } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección +- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . $userData['country'] . ', ' . ' - ' . $userData['pin_code']; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -113) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:193 [M] MethodCallRemoval +83) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] ConcatOperandRemoval --- Original +++ New @@ @@ - $order->setUserId($row['user_id']); - $order->setName($row['name']); - $order->setNumber($row['number']); -- $order->setEmail($row['email']); -+ - $order->setMethod($row['method']); - $order->setAddress($row['address']); - $order->setTotalProducts($row['total_products']); + } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección +- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['pin_code']; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -114) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:194 [M] MethodCallRemoval +84) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] Concat --- Original +++ New @@ @@ - $order->setName($row['name']); - $order->setNumber($row['number']); - $order->setEmail($row['email']); -- $order->setMethod($row['method']); -+ - $order->setAddress($row['address']); - $order->setTotalProducts($row['total_products']); - $order->setTotalPrice($row['total_price']); + } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección +- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . ' - ' . $userData['country'] . $userData['pin_code']; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -115) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:195 [M] MethodCallRemoval +85) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] ConcatOperandRemoval --- Original +++ New @@ @@ - $order->setNumber($row['number']); - $order->setEmail($row['email']); - $order->setMethod($row['method']); -- $order->setAddress($row['address']); -+ - $order->setTotalProducts($row['total_products']); - $order->setTotalPrice($row['total_price']); - $order->setPaymentStatus($row['payment_status']); + } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección +- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code']; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -116) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:196 [M] MethodCallRemoval +86) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] Concat --- Original +++ New @@ @@ - $order->setEmail($row['email']); - $order->setMethod($row['method']); - $order->setAddress($row['address']); -- $order->setTotalProducts($row['total_products']); -+ - $order->setTotalPrice($row['total_price']); - $order->setPaymentStatus($row['payment_status']); - $order->setPlacedOn($row['placed_on']); + } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección +- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . $userData['pin_code'] . ' - '; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -117) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:197 [M] MethodCallRemoval +87) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:123 [M] ConcatOperandRemoval --- Original +++ New @@ @@ - $order->setMethod($row['method']); - $order->setAddress($row['address']); - $order->setTotalProducts($row['total_products']); -- $order->setTotalPrice($row['total_price']); -+ - $order->setPaymentStatus($row['payment_status']); - $order->setPlacedOn($row['placed_on']); - $orders[] = $order; + } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección +- $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; ++ $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - '; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); -118) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:198 [M] MethodCallRemoval +88) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:130 [M] MethodCallRemoval --- Original +++ New @@ @@ - $order->setAddress($row['address']); - $order->setTotalProducts($row['total_products']); - $order->setTotalPrice($row['total_price']); -- $order->setPaymentStatus($row['payment_status']); -+ - $order->setPlacedOn($row['placed_on']); - $orders[] = $order; - } + $totalProducts = implode(', ', $products); + // Formatear y establecer dirección + $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; +- // Establecer valores adicionales en el objeto Order +- $order->setAddress($address); ++ + $order->setTotalProducts($totalProducts); + $order->setTotalPrice($cartTotal); + // Verificar si la orden ya existe -119) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:199 [M] MethodCallRemoval +89) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:131 [M] MethodCallRemoval --- Original +++ New @@ @@ - $order->setTotalProducts($row['total_products']); - $order->setTotalPrice($row['total_price']); - $order->setPaymentStatus($row['payment_status']); -- $order->setPlacedOn($row['placed_on']); -+ - $orders[] = $order; - } - return $orders; + $address = 'flat no. ' . $userData['flat'] . ', ' . $userData['street'] . ', ' . $userData['city'] . ', ' . $userData['country'] . ' - ' . $userData['pin_code']; + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); +- $order->setTotalProducts($totalProducts); ++ + $order->setTotalPrice($cartTotal); + // Verificar si la orden ya existe + $stmt = $this->conn->prepare("SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?"); -120) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:216 [M] MethodCallRemoval +90) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:132 [M] MethodCallRemoval --- Original +++ New @@ @@ - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - $product = new Product(); - $product->setName($row['name']); -- $product->setPrice($row['price']); -+ - $product->setImage($row['image']); - $products[] = $product; - } + // Establecer valores adicionales en el objeto Order + $order->setAddress($address); + $order->setTotalProducts($totalProducts); +- $order->setTotalPrice($cartTotal); ++ + // Verificar si la orden ya existe + $stmt = $this->conn->prepare("SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?"); + $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]); -121) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:217 [M] MethodCallRemoval +91) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:140 [M] ArrayItemRemoval --- Original +++ New @@ @@ - $product = new Product(); - $product->setName($row['name']); - $product->setPrice($row['price']); -- $product->setImage($row['image']); -+ - $products[] = $product; + $order->setTotalPrice($cartTotal); + // Verificar si la orden ya existe + $stmt = $this->conn->prepare("SELECT * FROM orders WHERE \r\n name = ? AND number = ? AND email = ? AND \r\n method = ? AND address = ? AND \r\n total_products = ? AND total_price = ?"); +- $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]); ++ $stmt->execute([$order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice()]); + if ($stmt->rowCount() > 0) { + return ['success' => false, 'message' => '¡Pedido ya realizado!']; } - return $products; -122) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:222 [M] MethodCallRemoval +92) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:160 [M] ArrayItemRemoval --- Original +++ New @@ @@ } - return $products; - } catch (\Exception $e) { -- $this->handleDatabaseError($e); -+ - return []; - } - } + // Insertar nueva orden + $stmt = $this->conn->prepare("INSERT INTO orders \r\n (user_id, name, number, email, method, address, \r\n total_products, total_price, placed_on) \r\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); +- $stmt->execute([$order->getUserId(), $order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]); ++ $stmt->execute([$order->getName(), $order->getNumber(), $order->getEmail(), $order->getMethod(), $order->getAddress(), $order->getTotalProducts(), $order->getTotalPrice(), date('d-M-Y')]); + // Limpiar carrito + $this->clearCart($userId); + return ['success' => true, 'message' => '¡Pedido realizado con éxito!']; -123) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:235 [M] MethodCallRemoval +93) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:190 [M] ArrayItemRemoval --- Original +++ New @@ @@ - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - $user = new User(); - $user->setName($row['name']); -- $user->setEmail($row['email']); -+ - $user->setUserType($row['user_type']); - $users[] = $user; - } + private function clearCart($userId) + { + $stmt = $this->conn->prepare("DELETE FROM cart WHERE user_id = ?"); +- $stmt->execute([$userId]); ++ $stmt->execute([]); + } + public function getUserOrders($userId) + { -124) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:236 [M] MethodCallRemoval +94) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:202 [M] MethodCallRemoval --- Original +++ New @@ @@ - $user = new User(); - $user->setName($row['name']); - $user->setEmail($row['email']); -- $user->setUserType($row['user_type']); + $order = new Order(); + $order->setUserId($row['user_id']); + $order->setName($row['name']); +- $order->setNumber($row['number']); + - $users[] = $user; - } - return $users; + $order->setEmail($row['email']); + $order->setMethod($row['method']); + $order->setAddress($row['address']); -125) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:241 [M] MethodCallRemoval +95) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:214 [M] Concat --- Original +++ New @@ @@ } - return $users; + return $orders; } catch (\Exception $e) { -- $this->handleDatabaseError($e); -+ +- error_log("Error al obtener órdenes del usuario: " . $e->getMessage()); ++ error_log($e->getMessage() . "Error al obtener órdenes del usuario: "); return []; } } -126) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:247 [M] Concat +96) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:214 [M] ConcatOperandRemoval --- Original +++ New @@ @@ + } + return $orders; + } catch (\Exception $e) { +- error_log("Error al obtener órdenes del usuario: " . $e->getMessage()); ++ error_log($e->getMessage()); + return []; + } } - private function handleDatabaseError(\Exception $e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ error_log($e->getMessage() . "Error en la base de datos: "); - } - } -127) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:247 [M] ConcatOperandRemoval +97) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:214 [M] ConcatOperandRemoval --- Original +++ New @@ @@ + } + return $orders; + } catch (\Exception $e) { +- error_log("Error al obtener órdenes del usuario: " . $e->getMessage()); ++ error_log("Error al obtener órdenes del usuario: "); + return []; + } } - private function handleDatabaseError(\Exception $e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ error_log($e->getMessage()); - } - } -128) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:247 [M] ConcatOperandRemoval +98) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:214 [M] FunctionCallRemoval --- Original +++ New @@ @@ + } + return $orders; + } catch (\Exception $e) { +- error_log("Error al obtener órdenes del usuario: " . $e->getMessage()); ++ + return []; + } } - private function handleDatabaseError(\Exception $e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ error_log("Error en la base de datos: "); - } - } -129) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:247 [M] FunctionCallRemoval +99) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\OrderController.php:232 [M] MethodCallRemoval --- Original +++ New @@ @@ + } + return $products; + } catch (\Exception $e) { +- $this->handleDatabaseError($e); ++ + return []; + } } - private function handleDatabaseError(\Exception $e) - { -- error_log("Error en la base de datos: " . $e->getMessage()); -+ - } - } -130) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:17 [M] DecrementInteger +100) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:17 [M] DecrementInteger --- Original +++ New @@ -1953,7 +1508,7 @@ Escaped mutants: $query = "SELECT * FROM products LIMIT :limit"; -131) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:17 [M] IncrementInteger +101) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:17 [M] IncrementInteger --- Original +++ New @@ -1968,7 +1523,7 @@ Escaped mutants: $query = "SELECT * FROM products LIMIT :limit"; -132) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:21 [M] MethodCallRemoval +102) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:21 [M] MethodCallRemoval --- Original +++ New @@ -1983,7 +1538,7 @@ Escaped mutants: foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { -133) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:27 [M] MethodCallRemoval +103) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:27 [M] MethodCallRemoval --- Original +++ New @@ -1998,7 +1553,7 @@ Escaped mutants: $product->setImage($row['image']); -134) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:29 [M] MethodCallRemoval +104) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:29 [M] MethodCallRemoval --- Original +++ New @@ -2013,7 +1568,7 @@ Escaped mutants: } -135) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:30 [M] MethodCallRemoval +105) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:30 [M] MethodCallRemoval --- Original +++ New @@ -2028,7 +1583,7 @@ Escaped mutants: return $products; -136) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] Concat +106) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] Concat --- Original +++ New @@ -2043,7 +1598,7 @@ Escaped mutants: } -137) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] ConcatOperandRemoval +107) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] ConcatOperandRemoval --- Original +++ New @@ -2058,7 +1613,7 @@ Escaped mutants: } -138) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] ConcatOperandRemoval +108) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] ConcatOperandRemoval --- Original +++ New @@ -2073,7 +1628,7 @@ Escaped mutants: } -139) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] FunctionCallRemoval +109) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:35 [M] FunctionCallRemoval --- Original +++ New @@ -2088,7 +1643,7 @@ Escaped mutants: } -140) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:62 [M] ArrayItemRemoval +110) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:62 [M] ArrayItemRemoval --- Original +++ New @@ -2103,7 +1658,7 @@ Escaped mutants: error_log("Error al añadir al carrito: " . $e->getMessage()); -141) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] Concat +111) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] Concat --- Original +++ New @@ -2118,7 +1673,7 @@ Escaped mutants: } -142) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] ConcatOperandRemoval +112) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] ConcatOperandRemoval --- Original +++ New @@ -2133,7 +1688,7 @@ Escaped mutants: } -143) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] ConcatOperandRemoval +113) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] ConcatOperandRemoval --- Original +++ New @@ -2148,7 +1703,7 @@ Escaped mutants: } -144) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] FunctionCallRemoval +114) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:72 [M] FunctionCallRemoval --- Original +++ New @@ -2163,7 +1718,7 @@ Escaped mutants: } -145) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:86 [M] MethodCallRemoval +115) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:86 [M] MethodCallRemoval --- Original +++ New @@ -2178,7 +1733,7 @@ Escaped mutants: $product->setImage($row['image']); -146) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:88 [M] MethodCallRemoval +116) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:88 [M] MethodCallRemoval --- Original +++ New @@ -2193,7 +1748,7 @@ Escaped mutants: } -147) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:89 [M] MethodCallRemoval +117) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:89 [M] MethodCallRemoval --- Original +++ New @@ -2208,7 +1763,7 @@ Escaped mutants: return $products; -148) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] Concat +118) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] Concat --- Original +++ New @@ -2223,7 +1778,7 @@ Escaped mutants: } -149) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] ConcatOperandRemoval +119) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] ConcatOperandRemoval --- Original +++ New @@ -2238,7 +1793,7 @@ Escaped mutants: } -150) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] ConcatOperandRemoval +120) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] ConcatOperandRemoval --- Original +++ New @@ -2253,7 +1808,7 @@ Escaped mutants: } -151) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] FunctionCallRemoval +121) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:94 [M] FunctionCallRemoval --- Original +++ New @@ -2268,7 +1823,7 @@ Escaped mutants: } -152) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] Concat +122) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] Concat --- Original +++ New @@ -2283,7 +1838,7 @@ Escaped mutants: } -153) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] ConcatOperandRemoval +123) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] ConcatOperandRemoval --- Original +++ New @@ -2298,7 +1853,7 @@ Escaped mutants: } -154) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] ConcatOperandRemoval +124) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] ConcatOperandRemoval --- Original +++ New @@ -2313,7 +1868,7 @@ Escaped mutants: } -155) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] FunctionCallRemoval +125) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:106 [M] FunctionCallRemoval --- Original +++ New @@ -2328,7 +1883,7 @@ Escaped mutants: } -156) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] Concat +126) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] Concat --- Original +++ New @@ -2344,7 +1899,7 @@ Escaped mutants: } -157) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] ConcatOperandRemoval +127) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] ConcatOperandRemoval --- Original +++ New @@ -2360,7 +1915,7 @@ Escaped mutants: } -158) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] ConcatOperandRemoval +128) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] ConcatOperandRemoval --- Original +++ New @@ -2376,7 +1931,7 @@ Escaped mutants: } -159) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] FunctionCallRemoval +129) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\ProductController.php:142 [M] FunctionCallRemoval --- Original +++ New @@ -2392,7 +1947,7 @@ Escaped mutants: } -160) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:25 [M] MethodCallRemoval +130) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:25 [M] MethodCallRemoval --- Original +++ New @@ -2407,7 +1962,7 @@ Escaped mutants: // Verificar si el correo ya existe -161) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:26 [M] MethodCallRemoval +131) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:26 [M] MethodCallRemoval --- Original +++ New @@ -2422,7 +1977,7 @@ Escaped mutants: $stmt = $this->conn->prepare("SELECT id FROM users WHERE email = ?"); -162) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:27 [M] Coalesce +132) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:27 [M] Coalesce --- Original +++ New @@ -2437,7 +1992,7 @@ Escaped mutants: $stmt->execute([$user->getEmail()]); -163) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:27 [M] MethodCallRemoval +133) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:27 [M] MethodCallRemoval --- Original +++ New @@ -2452,7 +2007,7 @@ Escaped mutants: $stmt->execute([$user->getEmail()]); -164) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:31 [M] ArrayItemRemoval +134) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:31 [M] ArrayItemRemoval --- Original +++ New @@ -2467,7 +2022,7 @@ Escaped mutants: } -165) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:31 [M] MethodCallRemoval +135) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:31 [M] MethodCallRemoval --- Original +++ New @@ -2482,7 +2037,7 @@ Escaped mutants: } -166) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] Concat +136) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] Concat --- Original +++ New @@ -2497,7 +2052,7 @@ Escaped mutants: } -167) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] ConcatOperandRemoval +137) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] ConcatOperandRemoval --- Original +++ New @@ -2512,7 +2067,7 @@ Escaped mutants: } -168) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] ConcatOperandRemoval +138) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] ConcatOperandRemoval --- Original +++ New @@ -2527,7 +2082,7 @@ Escaped mutants: } -169) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] FunctionCallRemoval +139) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:51 [M] FunctionCallRemoval --- Original +++ New @@ -2542,7 +2097,7 @@ Escaped mutants: } -170) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] Concat +140) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] Concat --- Original +++ New @@ -2557,7 +2112,7 @@ Escaped mutants: } -171) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] ConcatOperandRemoval +141) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] ConcatOperandRemoval --- Original +++ New @@ -2572,7 +2127,7 @@ Escaped mutants: } -172) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] ConcatOperandRemoval +142) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] ConcatOperandRemoval --- Original +++ New @@ -2587,7 +2142,7 @@ Escaped mutants: } -173) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] FunctionCallRemoval +143) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:72 [M] FunctionCallRemoval --- Original +++ New @@ -2602,7 +2157,37 @@ Escaped mutants: } -174) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] Concat +144) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:102 [M] ArrayItemRemoval + +--- Original ++++ New +@@ @@ + { + try { + $stmt = $this->conn->prepare("SELECT id, name, email, user_type FROM users WHERE id = ?"); +- $stmt->execute([$userId]); ++ $stmt->execute([]); + return $stmt->fetch(\PDO::FETCH_ASSOC); + } catch (\Exception $e) { + error_log("Error al obtener usuario: " . $e->getMessage()); + + +145) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:102 [M] MethodCallRemoval + +--- Original ++++ New +@@ @@ + { + try { + $stmt = $this->conn->prepare("SELECT id, name, email, user_type FROM users WHERE id = ?"); +- $stmt->execute([$userId]); ++ + return $stmt->fetch(\PDO::FETCH_ASSOC); + } catch (\Exception $e) { + error_log("Error al obtener usuario: " . $e->getMessage()); + + +146) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] Concat --- Original +++ New @@ -2617,7 +2202,7 @@ Escaped mutants: } -175) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] ConcatOperandRemoval +147) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] ConcatOperandRemoval --- Original +++ New @@ -2632,7 +2217,7 @@ Escaped mutants: } -176) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] ConcatOperandRemoval +148) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] FunctionCallRemoval --- Original +++ New @@ -2641,13 +2226,13 @@ Escaped mutants: return $stmt->fetch(\PDO::FETCH_ASSOC); } catch (\Exception $e) { - error_log("Error al obtener usuario: " . $e->getMessage()); -+ error_log("Error al obtener usuario: "); ++ return null; } } -177) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] FunctionCallRemoval +149) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Controllers\UserController.php:105 [M] ConcatOperandRemoval --- Original +++ New @@ -2656,13 +2241,13 @@ Escaped mutants: return $stmt->fetch(\PDO::FETCH_ASSOC); } catch (\Exception $e) { - error_log("Error al obtener usuario: " . $e->getMessage()); -+ ++ error_log("Error al obtener usuario: "); return null; } } -178) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Models\Message.php:30 [M] ArrayItemRemoval +150) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Models\Message.php:30 [M] ArrayItemRemoval --- Original +++ New @@ -2677,7 +2262,7 @@ Escaped mutants: public function save($conn) -179) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Models\Message.php:37 [M] ArrayItemRemoval +151) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Models\Message.php:37 [M] ArrayItemRemoval --- Original +++ New @@ -2692,7 +2277,7 @@ Escaped mutants: { -180) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Models\Order.php:44 [M] This +152) C:\Users\ASUS\Desktop\proyecto-si784-2024-ii-u3-reportes_chambilla_llantay\src\Models\Order.php:44 [M] This --- Original +++ New diff --git a/reports/mutations/per-mutator.md b/reports/mutations/per-mutator.md index ee10fe5e..9f45e712 100644 --- a/reports/mutations/per-mutator.md +++ b/reports/mutations/per-mutator.md @@ -2,32 +2,28 @@ | Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | Ignored | MSI (%s) | Covered MSI (%s) | | ---------------------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | ------- | -------- | ---------------- | -| ArrayItemRemoval | 63 | 50 | 12 | 0 | 0 | 1 | 0 | 0 | 80.95 | 80.95 | -| Assignment | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 66.67 | 66.67 | +| ArrayItemRemoval | 49 | 35 | 13 | 0 | 0 | 1 | 0 | 0 | 73.47 | 73.47 | | Coalesce | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0.00 | 0.00 | -| Concat | 39 | 9 | 28 | 0 | 0 | 2 | 0 | 0 | 28.21 | 28.21 | -| ConcatOperandRemoval | 67 | 19 | 44 | 0 | 0 | 4 | 0 | 0 | 34.33 | 34.33 | -| DecrementInteger | 6 | 4 | 2 | 0 | 0 | 0 | 0 | 0 | 66.67 | 66.67 | -| FalseValue | 26 | 25 | 1 | 0 | 0 | 0 | 0 | 0 | 96.15 | 96.15 | -| Foreach_ | 13 | 12 | 1 | 0 | 0 | 0 | 0 | 0 | 92.31 | 92.31 | +| Concat | 29 | 3 | 24 | 0 | 0 | 2 | 0 | 0 | 17.24 | 17.24 | +| ConcatOperandRemoval | 50 | 7 | 39 | 0 | 0 | 4 | 0 | 0 | 22.00 | 22.00 | +| DecrementInteger | 5 | 3 | 2 | 0 | 0 | 0 | 0 | 0 | 60.00 | 60.00 | +| FalseValue | 22 | 19 | 3 | 0 | 0 | 0 | 0 | 0 | 86.36 | 86.36 | +| Foreach_ | 14 | 13 | 1 | 0 | 0 | 0 | 0 | 0 | 92.86 | 92.86 | | FunctionCall | 2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| FunctionCallRemoval | 20 | 5 | 14 | 0 | 0 | 1 | 0 | 0 | 30.00 | 30.00 | -| GreaterThan | 6 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| GreaterThanNegotiation | 6 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| Identical | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | +| FunctionCallRemoval | 17 | 3 | 13 | 0 | 0 | 1 | 0 | 0 | 23.53 | 23.53 | +| GreaterThan | 5 | 4 | 1 | 0 | 0 | 0 | 0 | 0 | 80.00 | 80.00 | +| GreaterThanNegotiation | 5 | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | | IncrementInteger | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 50.00 | 50.00 | +| LessThan | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0.00 | 0.00 | +| LessThanNegotiation | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | | LogicalAnd | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| LogicalNot | 13 | 13 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| LogicalOr | 6 | 5 | 1 | 0 | 0 | 0 | 0 | 0 | 83.33 | 83.33 | -| MethodCallRemoval | 137 | 67 | 70 | 0 | 0 | 0 | 0 | 0 | 48.91 | 48.91 | -| Multiplication | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0.00 | 0.00 | +| LogicalNot | 7 | 7 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | +| LogicalOr | 3 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | +| MethodCallRemoval | 100 | 49 | 51 | 0 | 0 | 0 | 0 | 0 | 49.00 | 49.00 | | NewObject | 2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| NotIdentical | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| PlusEqual | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 66.67 | 66.67 | | ProtectedVisibility | 2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| PublicVisibility | 97 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | +| PublicVisibility | 98 | 98 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | | Ternary | 4 | 2 | 0 | 0 | 0 | 2 | 0 | 0 | 100.00 | 100.00 | | This | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 50.00 | 50.00 | -| Throw_ | 3 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 100.00 | 100.00 | -| TrueValue | 12 | 11 | 0 | 0 | 0 | 1 | 0 | 0 | 100.00 | 100.00 | -| UnwrapStrToLower | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 50.00 | 50.00 | +| Throw_ | 4 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 75.00 | 75.00 | +| TrueValue | 9 | 8 | 0 | 0 | 0 | 1 | 0 | 0 | 100.00 | 100.00 | diff --git a/reports/mutations/summary.log b/reports/mutations/summary.log index b7e72d6f..e5115c88 100644 --- a/reports/mutations/summary.log +++ b/reports/mutations/summary.log @@ -1,9 +1,9 @@ -Total: 541 +Total: 435 -Killed: 350 +Killed: 272 Errored: 0 Syntax Errors: 0 -Escaped: 180 +Escaped: 152 Timed Out: 11 Skipped: 0 Ignored: 0 diff --git a/src/Controllers/AdminController.php b/src/Controllers/AdminController.php index 4299ca4b..ef94fcc1 100644 --- a/src/Controllers/AdminController.php +++ b/src/Controllers/AdminController.php @@ -33,17 +33,21 @@ public function getDashboardData() { return $data; } - private function getTotalPendings() { - $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'pendiente'"); - $stmt->execute(); - $total = 0; - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { - $order = new Order(); - $order->setId($row['id']); - $order->setTotalPrice($row['total_price']); - $total += $order->getTotalPrice(); + public function getTotalPendings() { + try { + $stmt = $this->conn->prepare("SELECT * FROM `orders` WHERE payment_status = 'pendiente'"); + $stmt->execute(); + $total = 0; + foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + $order = new Order(); + $order->setId($row['id']); + $order->setTotalPrice($row['total_price']); + $total += $order->getTotalPrice(); + } + return $total; + } catch (\Exception $e) { + $this->handleDatabaseError($e); } - return $total; } private function getTotalCompleted() { diff --git a/src/Controllers/OrderController.php b/src/Controllers/OrderController.php index 4795a48e..336daee0 100644 --- a/src/Controllers/OrderController.php +++ b/src/Controllers/OrderController.php @@ -100,6 +100,16 @@ public function createOrder($userData, $userId) { return ['success' => false, 'message' => 'El carrito está vacío']; } + // Validar productos antes de procesar + foreach($cartItems as $item) { + if(empty($item['name'])) { + return ['success' => false, 'message' => 'Error: nombre de producto inválido']; + } + if($item['price'] < 0) { + return ['success' => false, 'message' => 'Error: precio inválido']; + } + } + // Calcular total y preparar lista de productos $cartTotal = 0; $products = []; diff --git a/tests/Unit/Controllers/AdminControllerTest.php b/tests/Unit/Controllers/AdminControllerTest.php index cef949f3..27674a63 100644 --- a/tests/Unit/Controllers/AdminControllerTest.php +++ b/tests/Unit/Controllers/AdminControllerTest.php @@ -611,4 +611,136 @@ public function testUpdateOrderStatusDatabaseError(): void $this->assertFalse($result); } + + /** @test */ + public function testGetSecureImagePathWithEmptyAndNonStringName(): void + { + $this->pdoStatement->method('execute')->willReturn(true); + $this->conn->method('prepare')->willReturn($this->pdoStatement); + + $reflection = new \ReflectionClass($this->adminController); + $method = $reflection->getMethod('getSecureImagePath'); + $method->setAccessible(true); + + // Caso 1: nombre vacío pero es string + $result1 = $method->invoke($this->adminController, ''); + $this->assertFalse($result1, 'Debería fallar con string vacío'); + + // Caso 2: no es string (número) + $result2 = $method->invoke($this->adminController, 123); + $this->assertFalse($result2, 'Debería fallar con número'); + + // Caso 3: null + $result3 = $method->invoke($this->adminController, null); + $this->assertFalse($result3, 'Debería fallar con null'); + + // Caso 4: array vacío + $result4 = $method->invoke($this->adminController, []); + $this->assertFalse($result4, 'Debería fallar con array'); + } + + /** @test */ + public function testGetSecureImagePathExtensionCaseSensitive(): void + { + $this->pdoStatement->method('execute')->willReturn(true); + $this->pdoStatement->method('fetch')->willReturn(['image' => 'test.jpg']); + $this->conn->method('prepare')->willReturn($this->pdoStatement); + + $reflection = new \ReflectionClass($this->adminController); + $method = $reflection->getMethod('getSecureImagePath'); + $method->setAccessible(true); + + // Caso 1: extensión en mayúsculas - debería devolver una ruta válida + $result1 = $method->invoke($this->adminController, 'test.JPG'); + $this->assertIsString($result1, 'Debería aceptar extensión en mayúsculas'); + $this->assertStringContainsString('test.JPG', $result1); + + // Caso 2: extensión mixta - debería devolver una ruta válida + $result2 = $method->invoke($this->adminController, 'test.JpG'); + $this->assertIsString($result2, 'Debería aceptar extensión mixta'); + $this->assertStringContainsString('test.JpG', $result2); + + // Caso 3: extensión en minúsculas - debería devolver una ruta válida + $result3 = $method->invoke($this->adminController, 'test.jpg'); + $this->assertIsString($result3, 'Debería aceptar extensión en minúsculas'); + $this->assertStringContainsString('test.jpg', $result3); + } + + /** @test */ + public function testDeleteProductWithEmptyExecuteParams(): void + { + // Configurar el mock para el PDOStatement + $this->pdoStatement->method('fetch') + ->willReturn(['image' => 'test.jpg']); + + $this->pdoStatement->method('execute') + ->willReturn(false); + + $this->conn->method('prepare') + ->willReturn($this->pdoStatement); + + $result = $this->adminController->deleteProduct(1); + + $this->assertFalse($result['success']); + $this->assertEquals('Error al eliminar el producto', $result['message']); + } + + /** @test */ + public function obtener_total_pendientes_exitoso(): void + { + // Datos de prueba + $ordersData = [ + [ + 'id' => 1, + 'total_price' => 100, + 'payment_status' => 'pendiente' + ], + [ + 'id' => 2, + 'total_price' => 200, + 'payment_status' => 'pendiente' + ] + ]; + + // Configurar el mock de PDO y PDOStatement + $this->conn->expects($this->once()) + ->method('prepare') + ->with("SELECT * FROM `orders` WHERE payment_status = 'pendiente'") + ->willReturn($this->pdoStatement); + + $this->pdoStatement->expects($this->once()) + ->method('execute') + ->willReturn(true); + + $this->pdoStatement->expects($this->once()) + ->method('fetchAll') + ->with(\PDO::FETCH_ASSOC) + ->willReturn($ordersData); + + // Ejecutar el método y verificar resultado + $result = $this->adminController->getTotalPendings(); + + $this->assertEquals(300, $result); // 100 + 200 = 300 + } + + /** @test */ + public function obtener_total_pendientes_maneja_error_execute(): void + { + // Configurar el mock para simular un error en execute() + $this->conn->expects($this->once()) + ->method('prepare') + ->with("SELECT * FROM `orders` WHERE payment_status = 'pendiente'") + ->willReturn($this->pdoStatement); + + $this->pdoStatement->expects($this->once()) + ->method('execute') + ->willThrowException(new \PDOException('Error de base de datos')); + + // Verificar que se lanza la excepción + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Error al procesar la solicitud'); + + $this->adminController->getTotalPendings(); + } + } diff --git a/tests/Unit/Controllers/OrderControllerTest.php b/tests/Unit/Controllers/OrderControllerTest.php index 121379e8..200df3f1 100644 --- a/tests/Unit/Controllers/OrderControllerTest.php +++ b/tests/Unit/Controllers/OrderControllerTest.php @@ -104,6 +104,31 @@ public function obtener_pedidos_usuario(): void $this->assertSame($userId, $result[0]->getUserId()); } + /** @test */ + public function obtener_pedidos_usuario_cuando_estan_vacios(): void + { + $userId = 1; + + // Configurar el mock para devolver un array vacío + $this->conn->expects($this->once()) + ->method('prepare') + ->willReturn($this->pdoStatement); + + $this->pdoStatement->expects($this->once()) + ->method('execute') + ->with([$userId]); + + $this->pdoStatement->expects($this->once()) + ->method('fetchAll') + ->willReturn([]); + + $result = $this->orderController->getUserOrders($userId); + + // Verificaciones + $this->assertIsArray($result); + $this->assertEmpty($result); + } + /** @test */ public function actualizar_estado_pago(): void { @@ -474,4 +499,125 @@ public function crear_pedido_con_foreach_array_vacio(): void $this->assertFalse($result['success']); $this->assertEquals('El carrito está vacío', $result['message']); } + + /** @test */ + public function obtener_todos_pedidos_con_datos_nulos(): void + { + // Simular una fila con datos nulos + $expectedOrders = [ + [ + 'user_id' => null, + 'name' => null, + 'email' => null, + 'method' => null, + 'address' => null, + 'total_products' => null, + 'total_price' => null + ] + ]; + + $this->conn->expects($this->once()) + ->method('prepare') + ->willReturn($this->pdoStatement); + + $this->pdoStatement->expects($this->once()) + ->method('execute'); + + $this->pdoStatement->expects($this->once()) + ->method('fetchAll') + ->willReturn($expectedOrders); + + $result = $this->orderController->getAllOrders(); + + // Verificaciones + $this->assertNotEmpty($result); + $this->assertIsArray($result); + $this->assertCount(1, $result); + + // Verificar que los getters devuelvan null o valores por defecto + $this->assertNull($result[0]->getUserId()); + $this->assertNull($result[0]->getName()); + $this->assertNull($result[0]->getEmail()); + $this->assertNull($result[0]->getMethod()); + $this->assertNull($result[0]->getAddress()); + $this->assertNull($result[0]->getTotalProducts()); + $this->assertNull($result[0]->getTotalPrice()); + } + + /** @test */ + public function crear_pedido_con_total_negativo(): void + { + $userId = 1; + $userData = [ + 'name' => 'Juan Pérez', + 'number' => '123456789', + 'email' => 'juan@test.com', + 'method' => 'credit card', + 'flat' => '123', + 'street' => 'Calle Principal', + 'city' => 'Lima', + 'country' => 'Perú', + 'pin_code' => '12345' + ]; + + $cartItems = [ + [ + 'name' => 'Producto 1', + 'quantity' => 2, + 'price' => -50 // Precio negativo + ] + ]; + + $this->conn->expects($this->once()) + ->method('prepare') + ->willReturn($this->pdoStatement); + + $this->pdoStatement->expects($this->once()) + ->method('fetchAll') + ->willReturn($cartItems); + + $result = $this->orderController->createOrder($userData, $userId); + + $this->assertFalse($result['success']); + $this->assertEquals('Error: precio inválido', $result['message']); + } + + /** @test */ + public function crear_pedido_con_nombre_producto_vacio(): void + { + $userId = 1; + $userData = [ + 'name' => 'Juan Pérez', + 'number' => '123456789', + 'email' => 'juan@test.com', + 'method' => 'credit card', + 'flat' => '123', + 'street' => 'Calle Principal', + 'city' => 'Lima', + 'country' => 'Perú', + 'pin_code' => '12345' + ]; + + $cartItems = [ + [ + 'name' => '', // Nombre vacío + 'quantity' => 2, + 'price' => 100 + ] + ]; + + $this->conn->expects($this->once()) + ->method('prepare') + ->willReturn($this->pdoStatement); + + $this->pdoStatement->expects($this->once()) + ->method('fetchAll') + ->willReturn($cartItems); + + $result = $this->orderController->createOrder($userData, $userId); + + $this->assertFalse($result['success']); + $this->assertEquals('Error: nombre de producto inválido', $result['message']); + } + } \ No newline at end of file